关于crontab的学习总结

时间:2023-02-06 07:59:22

 

 

一、常用定时任务总结:

1、每分钟执行一次:

* * * * *

 

2、每小时执行一次 :

0 * * * *

 

二、关于 crontab 的执行方式:(只写php和sh脚本的)

1、运行 xxx.sh

命令行:

sh xxx.sh

 

2、运行 xx.php

命令行:

/usr/local/bin/php /home/xx/www/console.php crontab backcountrystartcrawl >> /home/cron/log/backcountry_error.log &

 

3、使用 curl 运行xx.php

命令行:

/home/curl/curl/src/curl http://xx/test/Taobao/ReiStartCrawl &

 

三、关于简单的sh脚本的写法:

xx.sh

upt=`curl http://www.haitao.com/xx.php`;

upt=`php /ss/ss/xx.php`;

外部在crontab里运行这个sh的方式:

* * * * * xx.sh

每分钟运行这个sh脚本一次

 

& 表示即使程序关闭,也继续运行这个程序。