How to run a cronjob every X minutes?

前端 未结 6 1073
走了就别回头了
走了就别回头了 2020-11-30 23:40

I\'m running a PHP script in a cronjob and I want to send emails every 5 minutes

My current (crontab) cronjob:

10 * * * * /usr/bin/php /mydomain.in/c         


        
6条回答
  •  星月不相逢
    2020-12-01 00:33

    Your CRON should look like this:

    */5 * * * *

    CronWTF is really usefull when you need to test out your CRON settings.

    Might be a good idea to pipe the output into a log file so you can see if your script is throwing any errors too - since you wont see them in your terminal.

    Also try using a shebang at the top of your PHP file, so the system knows where to find PHP. Such as:

    #!/usr/bin/php

    that way you can call the whole thing like this

    */5 * * * * php /path/to/script.php > /path/to/logfile.log

提交回复
热议问题