We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Cron jobs not running in VestaCP (CentOs)
Cron jobs not running in VestaCP (CentOs)
I have written some PHP scripts that I am trying to run with cron jobs in VestaCP, but they don't seem to be running. I have tried to search for other threads on here that could help me identify the error, but have not found a solution.
Server system:
CentOs 7.4
Vesta 0.9.8-22
I have tested the PHP scripts by going to the links directly. They all work well. But the cron jobs are not running and I can't figure out why.
I have not been able to locate any error messages or logs generated by these cron jobs (even when I remove the "> /dev/null 2>&1"). But I might have been looking in the wrong places.
All of the cron jobs have been added through the VestaCP cron interface.
Copied from /var/spool/cron/admin [edited domain name]:
15 02 * * * sudo /usr/local/vesta/bin/v-update-sys-queue disk
10 00 * * * sudo /usr/local/vesta/bin/v-update-sys-queue traffic
30 03 * * * sudo /usr/local/vesta/bin/v-update-sys-queue webstats
*/5 * * * * sudo /usr/local/vesta/bin/v-update-sys-queue backup
10 05 * * * sudo /usr/local/vesta/bin/v-backup-users
20 00 * * * sudo /usr/local/vesta/bin/v-update-user-stats
*/5 * * * * sudo /usr/local/vesta/bin/v-update-sys-rrd
15 6 * * * sudo /usr/local/vesta/bin/v-update-sys-vesta-all
01 4 * * * sudo /usr/local/vesta/bin/v-update-letsencrypt-ssl
*/5 * * * * wget -q -O - "https://testing.example.com/cli/new-projects" > /dev/null 2>&1
*/5 * * * * wget -q -O - "https://example.com/cli/new-projects" > /dev/null 2>&1
30 10 * * * wget -q -O - "https://example.com/cli/project-expiration" > /dev/null 2>&1
*/5 * * * * sudo /usr/local/vesta/bin/v-update-sys-queue letsencrypt
0 10 * * * wget -q -O - "https://testing.example.com/cli/project-expiration" > /dev/null 2>&1
*/2 * * * * wget -q -O - "https://testing.example.com/cli/email-sender" > /dev/null 2>&1
*/2 * * * * wget -q -O - "https://example.com/cli/email-sender" > /dev/null 2>&1
Server system:
CentOs 7.4
Vesta 0.9.8-22
I have tested the PHP scripts by going to the links directly. They all work well. But the cron jobs are not running and I can't figure out why.
I have not been able to locate any error messages or logs generated by these cron jobs (even when I remove the "> /dev/null 2>&1"). But I might have been looking in the wrong places.
All of the cron jobs have been added through the VestaCP cron interface.
Copied from /var/spool/cron/admin [edited domain name]:
15 02 * * * sudo /usr/local/vesta/bin/v-update-sys-queue disk
10 00 * * * sudo /usr/local/vesta/bin/v-update-sys-queue traffic
30 03 * * * sudo /usr/local/vesta/bin/v-update-sys-queue webstats
*/5 * * * * sudo /usr/local/vesta/bin/v-update-sys-queue backup
10 05 * * * sudo /usr/local/vesta/bin/v-backup-users
20 00 * * * sudo /usr/local/vesta/bin/v-update-user-stats
*/5 * * * * sudo /usr/local/vesta/bin/v-update-sys-rrd
15 6 * * * sudo /usr/local/vesta/bin/v-update-sys-vesta-all
01 4 * * * sudo /usr/local/vesta/bin/v-update-letsencrypt-ssl
*/5 * * * * wget -q -O - "https://testing.example.com/cli/new-projects" > /dev/null 2>&1
*/5 * * * * wget -q -O - "https://example.com/cli/new-projects" > /dev/null 2>&1
30 10 * * * wget -q -O - "https://example.com/cli/project-expiration" > /dev/null 2>&1
*/5 * * * * sudo /usr/local/vesta/bin/v-update-sys-queue letsencrypt
0 10 * * * wget -q -O - "https://testing.example.com/cli/project-expiration" > /dev/null 2>&1
*/2 * * * * wget -q -O - "https://testing.example.com/cli/email-sender" > /dev/null 2>&1
*/2 * * * * wget -q -O - "https://example.com/cli/email-sender" > /dev/null 2>&1
-
- Support team
- Posts: 1096
- Joined: Sat Sep 06, 2014 9:58 pm
- Contact:
- Os: Debian 8x
- Web: apache + nginx
Re: Cron jobs not running in VestaCP (CentOs)
try running your commands in shell first and see if they execute fine. A couple of things to try:
1. Run command with sudo
2. catch your output in a log file
3. May be PHP is not executing the script... try piping the script to /usr/bin/php
1. Run command with sudo
2. catch your output in a log file
Code: Select all
wget -O - -q http://www.example.com/myscript.php >> log.txt
Re: Cron jobs not running in VestaCP (CentOs)
Thanks for the suggestions, mehargags! I have tested them out now.
1. Adding sudo to the commands does not seem to make a difference.
2. I changed one of the commands to the format you suggested, but can't find log.txt anywhere. I expected it to appear in either the top directory or in /var/log. Does it show up somewhere else? I'm not very experienced with linux :(
3. The PHP scripts work fine when I run these commands form the command line or visit the urls in a browser. And the scripts exist within a CodeIgniter framework, so moving them to a stand alone location isn't really an option.
Also, I found upon further inspection that some of the commands actually run, just not all of them. Specifically, this one does run:
While this one does not:
They contain the exact same script and they both work from the browser/command line.
While looking for logs, I found that they have all run some times, just very rarely. I found these logs in var/log:
In these logs, all the jobs are listed as run, but within very specific time intervals between 3:30 and 4:00.
I read somewhere else that similar issues have occurred when someone has not added a linebreak at the end of the crontab, so I'm suspecting that may be an issue. But I have added all of these cron jobs through the Vesta interface, so I don't know if it could be.
I'm really at a loss here, so if anyone has any further suggestions for debugging, I would really appreciate the help!
1. Adding sudo to the commands does not seem to make a difference.
2. I changed one of the commands to the format you suggested, but can't find log.txt anywhere. I expected it to appear in either the top directory or in /var/log. Does it show up somewhere else? I'm not very experienced with linux :(
3. The PHP scripts work fine when I run these commands form the command line or visit the urls in a browser. And the scripts exist within a CodeIgniter framework, so moving them to a stand alone location isn't really an option.
Also, I found upon further inspection that some of the commands actually run, just not all of them. Specifically, this one does run:
Code: Select all
*/2 * * * * wget -q -O - "https://testing.example.com/cli/email-sender" > /dev/null 2>&1
Code: Select all
*/2 * * * * wget -q -O - "https://example.com/cli/email-sender" > /dev/null 2>&1
While looking for logs, I found that they have all run some times, just very rarely. I found these logs in var/log:
Code: Select all
cron-20180513
cron-20180521
cron-20180527
cron-20180604
I read somewhere else that similar issues have occurred when someone has not added a linebreak at the end of the crontab, so I'm suspecting that may be an issue. But I have added all of these cron jobs through the Vesta interface, so I don't know if it could be.
I'm really at a loss here, so if anyone has any further suggestions for debugging, I would really appreciate the help!
-
- Support team
- Posts: 1096
- Joined: Sat Sep 06, 2014 9:58 pm
- Contact:
- Os: Debian 8x
- Web: apache + nginx
Re: Cron jobs not running in VestaCP (CentOs)
Can't comment further without looking at your scripts. PM me details, I'll be happy to check them for you