-1

I have dedicated server having centos 6.6 and centos webpanel. Now I'm trying to set cron job from centos web panel. I had tried so many commands to run one php file each and every minute, but still cron job is not making my file run each minute. Further configuration: Kernel Version: 2.6.32-26-pve, Platform: i686, Distro Name: CentOS release 6.6 (Final), MySQL version: 5.1.73, PHP version: 5.4.27, Apache version: Apache/2.2.27. Below is the list of all commands I had tried. Please help me with cron job. Thanks.

* * * * * public_html/run.php
* * * * * /public_html/run.php
* * * * * /bin/php -q /home/user_name/public_html/run.php
* * * * * run.php
* * * * * /run.php
* * * * * /public_html/run.php
* * * * * user_name/public_html/run.php
* * * * * ~user_name/public_html/run.php
* * * * * user_name /public_html/run.php
* * * * * user_name public_html/run.php
* * * * * user_name /run.php
* * * * * user_name run.php
* * * * * user_name /home/user_name/public_html/run.php
* * * * * user_name home/user_name/public_html/run.php
* * * * * /bin/php -q /home/user_name/public_html/run.php
* * * * * user_name /bin/php -q /home/user_name/public_html/run.php
* * * * * /usr/local/php -q /home/user_name/public_html/run.php
* * * * * user_name /usr/local/php -q /home/user_name/public_html/run.php
* * * * * /home/user_name/public_html/run.php
* * * * * home/user_name/public_html/run.php
* * * * * /usr/local/php -q home/user_name/public_html/run.php

I'm able to run this file from browser and it gives expected result also, but cron job is not able to run this file. Also I'm able to access this file in both ways, first using domain name like www.example.com/run.php and another method like http://my_ip_address/~user/run.php.

2

I think the nearest one should be:

* * * * * /usr/local/php -q /home/user_name/public_html/run.php

Notes:

  • All need absolute path
  • You need to find your php's absolute path by command which php. Mine is /usr/bin/php
  • You need to make sure you are editing the same user's crontab with crontab -e, and the same user can do a cat /home/user_name/public_html/run.php
  • Check whether daemon "crond" is running, by ps ax | grep crond. Should output a line like: 1251 ? Ss 1:51 crond
  • the last command outputs like: 836 ? Ss 0:00 crond 19320 pts/0 S+ 0:00 grep crond – RadhaComEng Feb 11 '15 at 5:06
  • Yes, crond is running. (for there is a line "crond" that is not "grep crond") – Johnny Wong Feb 11 '15 at 5:08
  • Do you run it successfully if you run on terminal: /usr/local/php /home/user_name/public_html/run.php ? – Johnny Wong Feb 11 '15 at 5:11
  • I had found the path and that is /usr/local/bin/php and set the cron job, now the php file run.php is for fetching content and it saves data to result directory as html pages, but still nothing is happening, please help me. I'm setting cron job from webpanel, May I set it from ssh terminal – RadhaComEng Feb 11 '15 at 5:12
  • getting error, Warning: file_put_contents(results/abc.html): failed to open stream: No such file or directory in /home/user_name/public_html/run.php on line 154 – RadhaComEng Feb 11 '15 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.