PDA

View Full Version : Cron Jobs - Restart Services


Mike
04-15-2005, 04:04 PM
How would I setup a cron job to restart lets say apache every night or once a week. I've got a table of time codes I've made up, but not really sure how to create them through root as I'm sure I'd have to so they have proper permissions?

Robert
04-17-2005, 03:52 AM
Login as the root user. Type in "crontab -e". That will let you add a cronjob to the root account. There should be several examples of the format to use.

If you need more help with crons, take a look at:

http://www.adminschoice.com/docs/crontab.htm

It's got a pretty handy guide you can use. :)

Hope that helps!

Mike
04-17-2005, 12:45 PM
Thanks Robert, that explains a lot. lol

I'll get some service commands setup tonight for restarting them.

I'll post the steps I took here so other users will know how to set them up for themselves.

Robert
04-18-2005, 06:11 AM
Good luck Mike! If it gives you any problems, let us know. Also... remember... if you want to cheat a little bit with CPanel, you can use the restart scripts inside of the /scripts folder.

CPanel has the following restart scripts available in the /scripts folder:

restartsrv_eximstats
restartsrv_postgres
restartsrv_ftpserver
restartsrv_postgresql
restartsrv_httpd
restartsrv_proftpd
restartsrv_apache
restartsrv_imap
restartsrv_pureftpd
restartsrv_bind
restartsrv_inetd
restartsrv_spamd
restartsrv_clamd
restartsrv_interchange
restartsrv_sshd
restartsrv_cppop
restartsrv_melange
restartsrv_syslogd
restartsrv_entropychat
restartsrv_mysql
restartsrv_tomcat
restartsrv_exim
restartsrv_named
restartsrv_xinetd

You'll notice some duplicates in there like restart apache and httpd. Either *should* work. Different sections in WHM use one or the other for some reason. *shrugs* I did not write the scripts. I just cheat and sometimes and look in that folder to see what's been done already.

Mike
05-11-2005, 01:44 PM
I've decided against doing this as I've noticed that sometimes when services are restarted they may not boot up 100% when they start up and I wont be there to restart it manually to make sure it's working. So I'll go back to just doing them manually once a week. ;)