Author Topic: Crontab will not work  (Read 15987 times)

0 Members and 2 Guests are viewing this topic.

Offline
*
Crontab will not work
« on: August 19, 2016, 05:32:45 PM »
Hello to all.

For each of my site I have a php file to be launched once a week via crontab.
This is the code I use
0 18 * * 3 /usr/local/bin/php -q /home/pornupda/public_html/mio-sito.com/cronojob.php

Why it does not work? It never starts ..
If you launch the file manually everything works perfectly.
I saw several threads on this forum seems to be the correct address.
So why it does not work?
« Last Edit: August 19, 2016, 05:37:56 PM by alebal »

Offline
*****
Re: Crontab will not work
« Reply #1 on: August 21, 2016, 10:00:56 AM »
Hello.

If your command:
Code: [Select]
/usr/local/bin/php -q /home/pornupda/public_html/mio-sito.com/cronojob.php  works fine, it will works with crontab too.
Try remove '-q' key, add and test it like:
Code: [Select]
* * * * * /usr/local/bin/php /home/pornupda/public_html/mio-sito.com/cronojob.php
You can ask me to solve any problem with your server for some money in pm  ;)
Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor
Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp

Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: Crontab will not work
« Reply #2 on: August 21, 2016, 09:04:18 PM »
Does not work...

These are the log. There you see something strange ???

Code: [Select]
Aug 21 00:00:01 centos-1gb-blr1-01 CROND[29994]: (root) CMD (/usr/sbin/csf --lfd restart > /dev/null 2>&1)
Aug 21 00:00:01 centos-1gb-blr1-01 CROND[29995]: (root) CMD (/usr/local/bin/svcMonitor)
Aug 21 00:01:01 centos-1gb-blr1-01 CROND[30523]: (root) CMD (run-parts /etc/cron.hourly)
Aug 21 00:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[30523]: starting 0anacron
Aug 21 00:01:01 centos-1gb-blr1-01 anacron[30532]: Anacron started on 2016-08-21
Aug 21 00:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[30534]: finished 0anacron
Aug 21 00:01:01 centos-1gb-blr1-01 anacron[30532]: Jobs will be executed sequentially
Aug 21 00:01:01 centos-1gb-blr1-01 anacron[30532]: Normal exit (0 jobs run)
Aug 21 00:20:01 centos-1gb-blr1-01 CROND[328]: (root) CMD (/usr/local/cwp/php54/bin/php -d max_execution_time=1000000 -q /usr/local/cwpsrv/htdocs/resources/admin/include/cron.php > /dev/null 2>&1)
Aug 21 01:00:01 centos-1gb-blr1-01 CROND[5144]: (root) CMD (/usr/local/bin/svcMonitor)
Aug 21 01:00:01 centos-1gb-blr1-01 CROND[5145]: (root) CMD (/usr/sbin/raid-check)
Aug 21 01:01:01 centos-1gb-blr1-01 CROND[5712]: (root) CMD (run-parts /etc/cron.hourly)
Aug 21 01:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[5712]: starting 0anacron
Aug 21 01:01:01 centos-1gb-blr1-01 anacron[5721]: Anacron started on 2016-08-21
Aug 21 01:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[5723]: finished 0anacron
Aug 21 01:01:01 centos-1gb-blr1-01 anacron[5721]: Jobs will be executed sequentially
Aug 21 01:01:01 centos-1gb-blr1-01 anacron[5721]: Normal exit (0 jobs run)
Aug 21 02:00:01 centos-1gb-blr1-01 CROND[14245]: (root) CMD (/usr/local/bin/svcMonitor)
Aug 21 02:01:01 centos-1gb-blr1-01 CROND[14698]: (root) CMD (run-parts /etc/cron.hourly)
Aug 21 02:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[14698]: starting 0anacron
Aug 21 02:01:01 centos-1gb-blr1-01 anacron[14707]: Anacron started on 2016-08-21
Aug 21 02:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[14709]: finished 0anacron
Aug 21 02:01:01 centos-1gb-blr1-01 anacron[14707]: Jobs will be executed sequentially
Aug 21 02:01:01 centos-1gb-blr1-01 anacron[14707]: Normal exit (0 jobs run)
Aug 21 03:00:01 centos-1gb-blr1-01 CROND[21114]: (root) CMD (/usr/local/bin/svcMonitor)
Aug 21 03:01:01 centos-1gb-blr1-01 CROND[21582]: (root) CMD (run-parts /etc/cron.hourly)
Aug 21 03:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[21582]: starting 0anacron
Aug 21 03:01:01 centos-1gb-blr1-01 anacron[21591]: Anacron started on 2016-08-21
Aug 21 03:01:01 centos-1gb-blr1-01 run-parts(/etc/cron.hourly)[21593]: finished 0anacron
Aug 21 03:01:01 centos-1gb-blr1-01 anacron[21591]: Will run job `cron.daily' in 27 min.
Aug 21 03:01:01 centos-1gb-blr1-01 anacron[21591]: Will run job `cron.weekly' in 47 min.
Aug 21 03:01:01 centos-1gb-blr1-01 anacron[21591]: Jobs will be executed sequentially
Aug 21 03:28:01 centos-1gb-blr1-01 anacron[21591]: Job `cron.daily' started
Aug 21 03:28:01 centos-1gb-blr1-01 run-parts(/etc/cron.daily)[25967]: starting certwatch
Aug 21 03:28:01 centos-1gb-blr1-01 run-parts(/etc/cron.daily)[25977]: finished certwatch
Aug 21 03:28:01 centos-1gb-blr1-01 run-parts(/etc/cron.daily)[25967]: starting cwp
Aug 21 03:28:16 centos-1gb-blr1-01 run-parts(/etc/cron.daily)[26102]: finished cwp
Aug 21 03:28:16 centos-1gb-blr1-01 run-parts(/etc/cron.daily)[25967]: starting logrotate

My test crontab was reduced to sending a mail ... but the email never arrives ...
CWP is on droplet digitalocean, digitalocean can create problems to the crontab?

Offline
*
Re: Crontab will not work
« Reply #3 on: August 22, 2016, 07:27:33 PM »
No, I want to use the server crontab. Why should I use an external service? for a fee. It is stupid.

Offline
*
Re: Crontab will not work
« Reply #4 on: August 22, 2016, 08:27:58 PM »
If I type via ssh crontab -e, this is the result

Code: [Select]
~
"/tmp/crontab.7Z7B4W" 0L, 0C


But it is normal ??

Offline
*****
Re: Crontab will not work
« Reply #5 on: August 23, 2016, 10:03:13 AM »
If I type via ssh crontab -e, this is the result

Code: [Select]
~
"/tmp/crontab.7Z7B4W" 0L, 0C


But it is normal ??


Yes, it's normal. Crontab using some tmp file while you writing the job.
You can ask me to solve any problem with your server for some money in pm  ;)
Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor
Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp

Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*****
Re: Crontab will not work
« Reply #6 on: August 23, 2016, 10:05:01 AM »
Does not work...

These are the log. There you see something strange ???

My test crontab was reduced to sending a mail ... but the email never arrives ...
CWP is on droplet digitalocean, digitalocean can create problems to the crontab?

I do not see any problems in the log.
You can ask me to solve any problem with your server for some money in pm  ;)
Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor
Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp

Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: Crontab will not work
« Reply #7 on: August 24, 2016, 03:46:19 PM »
Nothing ... still not working ...

I made these 2 files. The first writes the timestamp in a file.
Code: [Select]
$nome_file_index = $_SERVER['DOCUMENT_ROOT']."/cron_test.txt";
chmod($nome_file_index, 0666);
$file = fopen($nome_file_index, "w") ;
fwrite($file, time());
fclose($file);

It runs via cronjob every 30 minutes.
Code: [Select]
0 * * * * /usr/local/bin/php /home/pornupda/public_html/cron_test.php
30 * * * * /usr/local/bin/php /home/pornupda/public_html/cron_test.php

The second reads the file with the date.
Code: [Select]
$filename = "cron_test.txt";
$handle = fopen($filename, "r");
$crontest = fread($handle, filesize($filename));

echo 'Last cron '.date ("D d M Y H:i", $crontest);

It does not work ... That damned date never changes.