Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Jun 21, 2012 12:01 pm 
Offline

Joined: Thu Jun 21, 2012 11:55 am
Posts: 1
I searched the forums and didn't find anything:
search.php?keywords=cron+apache+restart&terms=all&author=&sc=1&sf=all&sk=t&sd=d&sr=posts&st=0&ch=300&t=0&submit=Search

Using Ubuntu 10.4, and would like to restart Apache every hour (for example).

This is not optimal solution, but I inherited a mess of a server and in the short term (while we figure out the REAL problem) we would like to recycle Apache once per hour. This does not really have an effect on our users as the site is mostly read only.

I'm a little weak in the CRON department, and would like to figure out a starting point.

Thanks in advance for your help!

-mxadmin


Top
   
PostPosted: Thu Jun 21, 2012 12:29 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
As root run
Code:
crontab -e
then add the following line
Code:
0 * * * * * /etc/init/apache2 restart

Save the crontab and then run
Code:
restart cron


Once you've fixed your problem just remove that line and restart cron again.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
PostPosted: Fri Jun 22, 2012 12:44 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
I agree with the general approach suggested by obs, but think there are a few typos in there, and would suggest running
Code:
crontab -e

and adding the following line
Code:
0 * * * * /etc/init.d/apache2 restart

(or you could use the following syntax instead)
Code:
@hourly /etc/init.d/apache2 restart

and then save the file and exit the editor. To disable this, just run crontab -e again and remove the line you added, save, and exit.

It should not be necessary to restart cron.

(man 5 crontab will tell you about the available syntax and give examples.)


Top
   
PostPosted: Fri Jun 22, 2012 9:31 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
Are you sure? At some point, Ubuntu got rid of crontab and the necessity to restart anything.


Top
   
PostPosted: Fri Jun 22, 2012 3:18 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
...Ok yeah I hadn't had my morning cup of tea yet when I wrote that....

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
PostPosted: Fri Jun 22, 2012 11:32 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
The crontab command appears to still be present in Ubuntu 10.04.


Top
   
PostPosted: Tue Jun 26, 2012 10:52 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
You're right, I'm remembering some other cron-related change in Ubuntu.


Top
   
PostPosted: Tue Jun 26, 2012 8:03 pm 
Offline
Senior Member

Joined: Sun May 23, 2010 1:57 pm
Posts: 315
Website: http://www.jebblue.net
If cron were to go away I'd leave Ubuntu and go to straight Debian or if that didn't work out
I'd go back to some RPM based distro.


Top
   
PostPosted: Tue Jun 26, 2012 9:31 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
If Linode stopped offering VPS service, I'd probably have to ditch them and go to Amazon; if that didn't work out, it's totally OpenVZ time.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group