doutui2883 2015-06-05 08:54 采纳率: 100%
浏览 37

PHP脚本不是由Linux服务器上的cron执行的

I host a couple of websites which have live twitter feeds. My set up means that each website has a tweets.php file that will get the tweets using twitter OAUTH and then write it to a text file. I then use a javascript file to get the JSON from the raw text (.txt) file.

Until I learnt about cron jobs I was refreshing the tweets.php files myself as part of my day-to-day admin.

However, I've set up my cron jobs and they don't seem to be executing the php file or writing to the text file (both have 777 permissions on them).

Furthermore, I have both a cron file created using crontab -e but there is also a directory called cron.hourly. As I wasn't sure which one to use I have put the cron jobs in both but they don't seem to be executing. Here are my files:

@daily /etc/webmin/mysql/backup.pl --all
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /etc/webmin/status/monitor.pl
0 * * * * /var/www/html/websiteone.co.uk/wp-content/themes/websiteone/tweets.php
0 * * * * /var/www/html/websitetwo.co.uk/wp-content/themes/websitetwo/tweets.php

And the cron file (called 'twitter') within the cron.hourly directory is:

/var/www/html/websiteone.co.uk/wp-content/themes/websiteone/tweets.php
/var/www/html/websitetwo.co.uk/wp-content/themes/websitetwo/tweets.php

Now I've checked the cron logs and they seem to be running the jobs hourly but the tweets aren't updating and neither is the raw text file.

08:00:01 ip-10-142-232-156 CROND[25986]: (root) CMD (/var/www/html/websitetwo.co.uk/wp-content/themes/websitetwo/tweets.php)
Jun  5 08:00:01 ip-10-142-232-156 CROND[25987]: (root) CMD (/etc/webmin/status/monitor.pl)
Jun  5 08:00:01 ip-10-142-232-156 CROND[25988]: (root) CMD (/var/www/html/websiteone.co.uk/wp-content/themes/websiteone/tweets.php)
Jun  5 08:01:01 ip-10-142-232-156 CROND[26014]: (root) CMD (run-parts /etc/cron.hourly)
Jun  5 08:01:01 ip-10-142-232-156 run-parts(/etc/cron.hourly)[26014]: starting 0anacron
Jun  5 08:01:01 ip-10-142-232-156 run-parts(/etc/cron.hourly)[26023]: finished 0anacron
Jun  5 08:01:01 ip-10-142-232-156 run-parts(/etc/cron.hourly)[26014]: starting twitter
Jun  5 08:01:01 ip-10-142-232-156 run-parts(/etc/cron.hourly)[26033]: finished twitter

Apologies if I'm missing something obvious but scheduled task automation is a new area for me.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch