Restart Apache2 each day via CRON ?
Restart Apache2 each day via CRON ?
Anyone knows how I get the Apache2 to restart each day at example 03:00 AM ?
I have already tried to make a CRON job with the following data:
00 03 * * *
sudo /usr/local/vesta/bin/v-restart-web
The Cron Daemon gives me following message:
sudo: no tty present and no askpass program specified Sorry, try again.
sudo: no tty present and no askpass program specified Sorry, try again.
sudo: no tty present and no askpass program specified Sorry, try again.
sudo: 3 incorrect password attempts
Any ideas how I set this up correctly via the cron interface?
I have already tried to make a CRON job with the following data:
00 03 * * *
sudo /usr/local/vesta/bin/v-restart-web
The Cron Daemon gives me following message:
sudo: no tty present and no askpass program specified Sorry, try again.
sudo: no tty present and no askpass program specified Sorry, try again.
sudo: no tty present and no askpass program specified Sorry, try again.
sudo: 3 incorrect password attempts
Any ideas how I set this up correctly via the cron interface?
Re: Restart Apache2 each day via CRON ?
Hello quatroweb,
Try do add this cron in the root crontab and don't use the sudo.
Regards,
Try do add this cron in the root crontab and don't use the sudo.
Regards,
Re: Restart Apache2 each day via CRON ?
Hi Kyon and thanks for your answer.
I tried what you mentioned and got following result:
Added the cron job with the root login to vestacp, but without sudo like this: /usr/local/vesta/bin/v-restart-web
And got this respond from Daemon:
/bin/sh: 1: /usr/local/vesta/bin/v-restart-web: Permission denied
After I tried with sudo like: sudo /usr/local/vesta/bin/v-restart-web
And got this respond from Daemon:
/usr/local/vesta/bin/v-restart-web: line 13: /func/main.sh: No such file or directory
/usr/local/vesta/bin/v-restart-web: line 14: /conf/vesta.conf: No such file or directory
It looks like the second time with sudo that it actually got permission, but don't have such directories?
Am I doing something wrong or miss something?
I tried what you mentioned and got following result:
Added the cron job with the root login to vestacp, but without sudo like this: /usr/local/vesta/bin/v-restart-web
And got this respond from Daemon:
/bin/sh: 1: /usr/local/vesta/bin/v-restart-web: Permission denied
After I tried with sudo like: sudo /usr/local/vesta/bin/v-restart-web
And got this respond from Daemon:
/usr/local/vesta/bin/v-restart-web: line 13: /func/main.sh: No such file or directory
/usr/local/vesta/bin/v-restart-web: line 14: /conf/vesta.conf: No such file or directory
It looks like the second time with sudo that it actually got permission, but don't have such directories?
Am I doing something wrong or miss something?
Re: Restart Apache2 each day via CRON ?
Hi,
Try something like "export VESTA=/usr/local/vesta/;sudo /usr/local/vesta/bin/v-restart-web".
Not with vestap but with the linux tool. In command line, as root user, you can type "crontab -e" and add the cron line without sudo but if your second test with sudo work, go to the next point ->, it's just for information :p.Added the cron job with the root login to vestacp,
This mean that the environment variable "VESTA" is missing./usr/local/vesta/bin/v-restart-web: line 13: /func/main.sh: No such file or directory
/usr/local/vesta/bin/v-restart-web: line 14: /conf/vesta.conf: No such file or directory
Try something like "export VESTA=/usr/local/vesta/;sudo /usr/local/vesta/bin/v-restart-web".
Re: Restart Apache2 each day via CRON ?
This is my cron jobs created by default in VestaCP
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
Each day I go to Services in VestaCP, but I want the apache2 to restart automatically without have to do it manually.
The question is, how do I add one more cron job in the file /var/spool/cron/admin for restarting the apache each day at 3 AM ?
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
Each day I go to Services in VestaCP, but I want the apache2 to restart automatically without have to do it manually.
The question is, how do I add one more cron job in the file /var/spool/cron/admin for restarting the apache each day at 3 AM ?
Re: Restart Apache2 each day via CRON ?
Try to use this command in vestacp cron
Code: Select all
export VESTA=/usr/local/vesta/;sudo /usr/local/vesta/bin/v-restart-service apache2
Code: Select all
00
03
*
*
*
export VESTA=/usr/local/vesta/;sudo /usr/local/vesta/bin/v-restart-service apache2
Re: Restart Apache2 each day via CRON ?
Worked like a charm!! Thanks a lot..
Re: Restart Apache2 each day via CRON ?
Anyone know how to restart the OS (example: Ubuntu) from cron?
I want to restart the hole Ubuntu 12.04, like you can actually do in Services in VestaCP at the top.
What I have at the moment is only for apache2:
Any suggestions, advice's, best practices etc.?
I want to restart the hole Ubuntu 12.04, like you can actually do in Services in VestaCP at the top.
What I have at the moment is only for apache2:
Code: Select all
export VESTA=/usr/local/vesta/;sudo /usr/local/vesta/bin/v-restart-service apache2
Re: Restart Apache2 each day via CRON ?
You should use system crontab for this
Code: Select all
/sbin/reboot
Re: Restart Apache2 each day via CRON ?
For 6 years - nobody cared to answer this... so here it is:
sudo /usr/local/vesta/bin/v-restart-system yes
Use above command in cron, and it should work without errors... for some reason, using /sbin/reboot does not work, even though the vesta script v-restart-system is internally using /sbin/reboot !!!
sudo /usr/local/vesta/bin/v-restart-system yes
Use above command in cron, and it should work without errors... for some reason, using /sbin/reboot does not work, even though the vesta script v-restart-system is internally using /sbin/reboot !!!