Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Need to have cron restart apache every hour
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6308
Location: /usr/lib64/lv2

PostPosted: Tue Jun 17, 2014 7:50 pm    Post subject: Need to have cron restart apache every hour Reply with quote

I've tried a couple of things to get cron to restart apache every hour, as it seems to hang frequently lately (yes, I know I should fix the actual problem, and I will, but I have too much on my plate right now).

I have fcron. What script should I use to force apache to restart every hour, and where do I put this script?
_________________
Gentoo Studio: A Gentoo-based, professional digital audio workstation OS.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Wed Jun 18, 2014 12:43 am    Post subject: Reply with quote

Unfortunately I don't use fcron.

For vixie-cron, which may be similar to fcron (if it also uses sys-process/cronbase which it very well might), it might be as simple as adding a script file that looks like (for openrc, not valid for systemd)

/etc/cron.hourly/apache-restarter wrote:
#!/bin/bash
/etc/init.d/apache2 restart

_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 6972
Location: Saint Amant, Acadiana

PostPosted: Wed Jun 18, 2014 12:47 am    Post subject: Reply with quote

This was the first hit in Google:

http://unix.stackexchange.com/questions/881/ensure-a-process-is-always-running

I personally use daemontools to keep processes that tend to crash running.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Wed Jun 18, 2014 12:51 am    Post subject: Reply with quote

Need to keep in mind the difference between a dying process and a hanging process...

I also question my solution whether that initscript will kill all children, you might need to do

/etc/cron.hourly/apache-restarter-version-2 wrote:
#!/bin/bash
/etc/init.d/apache2 stop
killall apache2
/etc/init.d/apache2 start


Ugh...Very ugly...

Fix your apache, not bandage it! :D
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6308
Location: /usr/lib64/lv2

PostPosted: Wed Jun 18, 2014 1:19 am    Post subject: Reply with quote

I appreciate the replies. Thanks! I agree, fixing it is best. I'll look into it some more. :)
_________________
Gentoo Studio: A Gentoo-based, professional digital audio workstation OS.
Back to top
View user's profile Send private message
skunk
l33t
l33t


Joined: 28 May 2003
Posts: 640
Location: granada, spain

PostPosted: Wed Jun 18, 2014 1:24 am    Post subject: Reply with quote

did you try lowering MaxRequestsPerChild?
restarting apache is a ugly hack and it won't always work because sometimes hung apache processes take a long time to get killed...
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6308
Location: /usr/lib64/lv2

PostPosted: Wed Jun 18, 2014 1:32 am    Post subject: Reply with quote

That might help. What would a good value other than 0 or 10000 be?
_________________
Gentoo Studio: A Gentoo-based, professional digital audio workstation OS.
Back to top
View user's profile Send private message
skunk
l33t
l33t


Joined: 28 May 2003
Posts: 640
Location: granada, spain

PostPosted: Wed Jun 18, 2014 1:34 am    Post subject: Reply with quote

anything in between? try with 2000...
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Wed Jun 18, 2014 2:53 am    Post subject: Reply with quote

I would think you would want something like 4 or 5 at most...
But I don't know the nature of the problem you're having...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Navar
Guru
Guru


Joined: 20 Aug 2012
Posts: 353

PostPosted: Wed Jun 18, 2014 4:40 am    Post subject: Reply with quote

Are you having DoS due to slow http attacks?
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 6308
Location: /usr/lib64/lv2

PostPosted: Wed Jun 18, 2014 6:27 pm    Post subject: Reply with quote

I noticed that stable Apache, PHP and MySQL in Portage were all well behind the official latest stable releases from those projects (latest stable MySQL isn't even in Portage), so I upgraded all those. I'm going to see if that takes care of things.
_________________
Gentoo Studio: A Gentoo-based, professional digital audio workstation OS.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum