how to run a php script daily with the cron job on Ubuntu os

前端 未结 4 866
情话喂你
情话喂你 2021-01-14 08:50

command to runI am using ubuntu 12 and lamp server . I want to run a php script after every 1 hour . i have create a crontab to execute this and if i check my cron list with

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 09:37

    You can use crontab to add/remove/edit cronjobs.

    Hit Alt+Ctrl+T to open terminal.

    First make sure the script is executable by running:

    chmod +x YOURSCRIPT
    

    Then run the following command to add your cronjob:

    crontab -e
    

    Add your cronjob like this:

    0 * * * * /usr/local/bin/php path/of/php/file
    

    That's it!

    Your can check the current user's crontab entries by running:

    crontab -l
    

    For more information about crontab run:

    crontab --help
    

    OR

    man crontab
    

提交回复
热议问题