简体   繁体   English

如何设置Cron作业-数字海洋中的PHP日常基础?

[英]How set cron job - PHP in digital ocean for daily bases?

I have set cron job command on my digital ocean server. 我在数字海洋服务器上设置了cron job命令。 0 1 * * * php /var/www/html/domain/cron/index.php is it right coded?? 0 1 * * * php /var/www/html/domain/cron/index.php是否正确编码? Because its not running daily. 因为它不是每天运行。 Had check of 5mint and hourly, its working fine but not for each day. 每小时检查5分钟,工作正常,但不是每天都有。 Please help me to find out the solution. 请帮助我找出解决方案。 Thanks in Advance. 提前致谢。

0 1 * * * means your php file will execute on 01:00:00, and this depend on your where your server is located (server's time zone). 0 1 * * *表示您的php文件将在01:00:00执行,这取决于服务器所在的位置(服务器的时区)。

Check this site. 检查此站点。 it will help you to set time for your cron job. 它将帮助您安排您的cron工作时间。

and if your cron is running for 5 minute, it should work for daily basis, you have to just figure out at what time it should run. 如果您的Cron运行5分钟,则它应该每天运行,那么您只需要弄清楚它应该在什么时间运行即可。

Check if your cron commands are OK by typing: 通过键入以下命令检查您的cron命令是否正常:

$ crontab -l

or right in 或就在

/var/spool/cron/crontab

Your command seems to be OK for a script that will be executed every day at 01AM. 对于每天凌晨01点执行的脚本,您的命令似乎正常。

Login to your droplet and then follow this steps 登录到您的Droplet,然后执行以下步骤

crontab -e
* * * * * cd project_path/ && php artisan schedule:run 1>> /dev/null 2>&1

Example: 例:

* * * * * cd /var/www/html/blog/ && php artisan schedule:run 1>> /dev/null 2>&1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM