Howto: Automatically Verify Cron / Crond Is Running And Restart If Not
May 30, 2005
This one's pretty simple really, but given the fact that I'm constantly running into crond stops with CPanel servers (no clue why, or where, but it's happening), I'll post this here. If it helps someone, then great, if not, hey, no worries.
Firstly, login as root to your server through ssh, however you usually do .
Next, the script (we'll call it /bin/croncheck.sh). Use whatever editor you choose to create the file.
how to setup a cron job to copy files & directories from one folder to the root folder. I have CPanel X.
My root directory is public_html/ I have another directory public_html/uploads containing both files and directories.
I need a cron job that will copy all the files & directories from public_html/uploads to the root public_html/
If it helps, here is some system info
General server information: Operating system Linux Service Status Click to View Kernel version 2.6.22_hg_grsec_pax Apache version 1.3.39 (Unix) PERL version 5.8.8 Path to PERL /usr/bin/perl Path to sendmail /usr/sbin/sendmail PHP version 4.4.4 MySQL version 4.1.22-standard cPanel Build 11.17.0-STABLE 19434 Theme cPanel X v2.6.0
almost daily my VPS httpd failed and restart automatically, after that all services show UP but my sites not working.. Only start working when I restart DNS Server (BIND).
i received 4 emails like this today, and now my sites are offline. what does "cpsrvd failed - A restart was attempted automagicly." mean and why are my sites now offline?
Anyone know a good script that I can run with cron or something? Mysql seems to be the #1 problem with a lot of my web sites, a restart usually fixes it right away for me, but I can't keep restarting my servers everyday manually.
I'm having a bit of trouble with one cron job that doesn't seem to work.
I have others scripts that run hourly fine. However this one does not.
The script:
restart_monitoring.sh
Code: #!/bin/bash service iptables stop service iptables start /root/bandwidth_rules.sh /root/portforward_config.sh exit The two scripts at the end just load a lot of iptables rules back in.
The cron job should run hourly (59th minute)
The cron job entry
Code: 59 * * * * /root/restart_monitoring.sh I have restart crond to enable the new job, still doesn't run.
The job is to restart iptables, thus flushing all rules that I have running, then reloading them. I have figured out the problem to be with the "service iptables stop/start" command, it doesn't seem to like doing this...?
ive got a fairly beefy server but at the moment its hosting alot of resource intensive sites (unfortunatly i dont currently have a choice on where to run them all) and apache is crashing to the point its taking upto 2 mins to load pages within about 24hours but once restarted is fine again. so im wondering if anyone can suggest a way to automaticly restart apache via a cron job every 24hours or so?
My host is experiencing "issues" with my WordPress. It keeps going above their upper limit of open MySQL connections. So, while I am diagnosing it, I need to restart the server every few hours to avoid it going down.
How do I write a cron to restart Apache every 3 hours?
*/5 * * * * /usr/local/bin/php -c /home/USER/php.ini /home/USER/public_html/poller.php > /dev/null 2>&1 I've checked my logs, and I can find no errors anywhere. When I run the commands manually via SSH, they work perfectly, they simply are not being run automatically the way they are supposed to be.
I have checked, and the crond service is running. I have tried restarting it, but it seams to have no affect. I really have no idea what the issue is. The only thing I seam to have found at one point, was the possibility that the files within the /etc/cron.d directory might be CHMOD'ed wrong, but I haven't found anything to confirm this either way.
[root@server cron.d]# ls -all total 60 drwxr-xr-x 2 root root 4096 Dec 17 03:07 . drwx--x--x 94 root root 12288 Jan 3 09:28 .. -rw-r--r-- 1 root root 61 Jun 22 2007 csf_update -rw-r--r-- 1 root root 81 Apr 11 2007 lsm -rw-r--r-- 1 root root 79 Jun 22 2007 prm -rw------- 1 root root 366 Feb 23 2007 sa-update -rw-r--r-- 1 root root 82 Jun 22 2007 spri -rw-r--r-- 1 root root 188 Nov 16 23:14 sysstat [root@server cron.d]#
I tried using this perl script which supposedly restarts apache when server load reaches 5 and above
Code: #!/usr/bin/perl -w #use strict; $|++; open(LOAD,"/proc/loadavg") || die "couldn't open /proc/loadavg: $! "; my @load=split(/ /,<LOAD>); close(LOAD); if ($load[0] > 5) { `/sbin/service httpd restart`; } and placed it in /usr/local/script/loadavg.pl and chmod to 755
and added this to my crontab
*/1 * * * * root /usr/local/script/loadavg.pl
my server load went up to 20 and waited if it will automatically go down via the script but it seems it's not working. I had to restart apache manually.
I have just recently moved to Plesk web admin from cpanel. I have been trying to get the cron to run for the past 48 hours but no luck. Bellow is the code i have been trying to execute via cron but It does not run.
"/usr/bin/php /var/www/ vhosts/mydomain. com /httpdocs/billing/index.php cron"
To me, this sounds really strange and really unrelated, hopefully it will ring a bell in somebody-who-reads-this' mind...
After enabled suexec in my webserver (litespeed), every day at two regular times, I notice a ton of crond processes on many different users. This slows down my entire server until they go away and it must be resolved.
I have only recently noticed that it is infact crond processes causing this and I hope I have finally found the correct issue. It causes a chain reaction of events and so I have slowly had to crawl up the chain to find the root of the issue... (high iowait, high swapping, high memory, normal processes taking up more cpu%, etc. etc. ........ crond processes)
I have checked every single file in /var/spool/cron and none of the cron jobs run remotely near these times (except some that run every minute/15 minutes for example). Also, I don't understand how so many crond processes could be made at once. I will make a better rough estimate when it next happens.
I've been attempting to develope a server running apache 2+, php 5, and I was running into issues installing php as cgi.... All my scripts require The shebang: #!/usr/bin/php at the top to execute properly. Anyone know a good site/how to that explains how to do this?
has anyone else here run suexec with apache? If so, could you tell me what you compiled it with? Just curious, as I think i'm doing everything right, yet I still fail
FFMPEG INSTALLATION FROM SOURCE FFMPEG INSTALLATION FROM SOURCE installed by: Robertas Dereskevicius Edited by Jon Nikolakakis OS/ Fedora Core 5
Summary download and install: libffac libffad2 xvid libogg,libvorbis mp3lame ffmpeg
Setting Up Install Folder, Logging and download Packages 1)Log into ssh 2) cd /usr/src && mkdir install && cd install 3) Download faad2 and faac from http://faac.sourceforge.net/oldsite/download.php get Faad2 and faac (new versions)
4) Verify that you have these components are installed rpm -qa automake rpm -qa autoconf rpm -qa libtool rpm -qa m4 rpm -qa gcc-c++
If any are missing than simply yum install (packagename), if you dont have a package manager than get one, it will save you alot of time and headaches.
Installing Faac 5)tar -zxvf faac-1.24.tar.gz && cd faac 6) sh bootstrap 7) ./configure 8) make 9) make install 10) cd ..
Installing Faad2 11) tar -zxvf faad2-2.0.tar.gz 12) cd faad2 && less README.linux 13) There is 2 bugs with this package, so need to manually edit these files 14) nano Makefile.am Edit the file to look like this SUBDIRS = libfaad common frontend plugins EXTRA_DIST = faad2.spec
15) cd common/mp4ff && nano mp4ffint.h 16) Comment out this line //void mp4ff_track_add(mp4ff_t *f);
17)Save file and cd ../.. 18)autoreconf -vif 19) ./configure 20) make 21) make install
Installing Libogg and Libvorbis 22)cd .. and then Check to see if libogg and libvorbs rpm -qa libogg-devel rpm -qa libvorbis-devel rpm -qa libncurses-devel
If not installed then simply Package Install (replace yum and install settings with your package manager) yum install libogg-devel yum install libvorbis-devel yum install libncurses-devel
i have 1 dedicated server, and 1 shared hosting the domain.com is hosted in dedicated server i want the subdomain sub.domain.com in other host
i have try this but not working :
I. the dedicated server have whm and cpanel
in whm i go to DNS Functions --> Edit DNS Zone --> i add sub name , choose A, and enter other ip host
II. the shared hosting only have cpanel
i go to cpanel --> addons domain --> add my domain.com then go to cpanel again --> Subdomains --> i add sub from domain.com
with above step i just got this when accessing the url http://sub.domain.com :
Quote:
Great Success ! Apache is working on your cPanel® and WHM™ Server If you can see this page, then the people who manage this server have installed cPanel and WebHost Manager (WHM) which use the Apache Web server software and the Apache Interface to OpenSSL (mod_ssl) successfully. They now have to add content to this directory and replace this placeholder page, or else point the server at their real content.
Anyone have any info on how to do this? It appears my hosts don't know how to do it..
"You have the tun module which can be loaded via a modprobe but the dev entries would appear to be needed to be made. Of course, you could do this if you know how or wait while I research it. We know tun/tap works on openvz but you're the first request we've had on Xen."
I'm on CentOS 4.4, webmin, LAMP, OpenSSH and ProFTPD server.
But what I'm wondering is how to look at my off network backup space.
I can only access my backup space through the DC network/my own server. So I need some kind of way to bounce a GUI ftp connection off the server - which would allow me to look at the files...
I know I can use rsync for backing up and restoring. But the way I understand rsync I need to know exactly what I am to move, as it operates on an exact command.
"You have the tun module which can be loaded via a modprobe but the dev entries would appear to be needed to be made. Of course, you could do this if you know how or wait while I research it. We know tun/tap works on openvz but you're the first request we've had on Xen."