简体   繁体   English

在 CENTOS 下运行 CRON JOBS

[英]Running CRON JOBS under CENTOS

I do not know what I am doing wrong.我不知道我做错了什么。 It appears that I cannot run crons under centos.看来我不能在centos下运行cron了。 I double checked the PHP path and the files path, they all seem ok to me.我仔细检查了 PHP 路径和文件路径,它们对我来说都很好。

59 23 * * 0 /usr/bin/php /home/fbk/public_html/.../pixel2life.php >> /var/log/mycron/pixel2life.log 2>&1
59 23 * * 1 /usr/bin/php /home/fbk/public_html/.../tutsplus.php >> /var/log/mycron/tutsplus.log 2>&1
59 23 * * 2 /usr/bin/php /home/fbk/public_html/.../tutorialzine.php >> /var/log/mycron/tutorialzine.log 2>&1
59 23 * * 3 /usr/bin/php /home/fbk/public_html/.../smashing.php >> /var/log/mycron/smashing.log 2>&1
59 23 * * 4 /usr/bin/php /home/fbk/public_html/.../makitweb.php >> /var/log/mycron/makitweb.log 2>&1
59 23 * * 5 /usr/bin/php /home/fbk/public_html/.../google.php >> /var/log/mycron/google.log 2>&1
59 23 * * 6 /usr/bin/php /home/fbk/public_html/.../hackr.php >> /var/log/mycron/hackr.log 2>&1
59 23 * * 0 /usr/bin/php /home/fbk/public_html/.../hackr2.php >> /var/log/mycron/hackr2.log 2>&1
59 23 * * 1 /usr/bin/php /home/fbk/public_html/.../hackr3.php >> /var/log/mycron/hackr3.log 2>&1

I also tried to create log files, but it appears that they do not get created.我也尝试创建日志文件,但似乎没有创建它们。 So, according to my cron, when creating them, I used the built in app from Webuzo not from crontab -e.因此,根据我的 cron,在创建它们时,我使用了 Webuzo 的内置应用程序,而不是 crontab -e。 I want them to run in specific days of the week from Sunday to Saturday and at 23:59.我希望他们在星期日到星期六的特定日期以及 23:59 运行。

First the problem with the logfiles: Often /var/log ist not writable for an ordinary user, and I guess, fbk is just an ordinary user;首先是日志文件的问题:通常 /var/log 对于普通用户来说是不可写的,我猜,fbk 只是一个普通用户; you should create a log directory in /home/fbk and write your logs into that directory.您应该在 /home/fbk 中创建一个日志目录并将您的日志写入该目录。 Maybe this already solves your problem.也许这已经解决了你的问题。

But if not, you should check the scripts by running them as user fbk on console without redirecting any output to any file.但如果没有,您应该通过在控制台上以用户 fbk 身份运行脚本来检查脚本,而不将任何输出重定向到任何文件。 This often shows the problem in case of errors.这通常会在出现错误时显示问题。 I do not know your mentioned app;我不知道你提到的应用程序; I always use crontab -e.我总是使用 crontab -e。

Btw: I hope, the three dots are just to shorten the path!? Btw:我希望,三个点只是为了缩短路径!? ;-) ;-)

如果您使用 Webuzo,只需使用 Webuzo PHP 二进制文件以 root 身份运行 PHP 文件:

/usr/local/emps/bin/php test.php

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

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