Script to check if a Linux service is running…

Sometimes my CrashPlan running on Linux will stop unexpectedly and you don’t know about it until there hasn’t been a backup for three days. 🙁

Here is a simple script that will check if your specified service is running and will start it if it’s stopped.

You will have to replace “replace_me_with_a_valid_service” with the name of the service you want to check


if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
echo "$service is running!!!"
/etc/init.d/$service start

You can place it in crontab and have it executed automatically
eg. to check every minute, insert into cron

* * * * * /path/to/script

with grateful thanks to

The reason I run a Linux box to backup CrashPlan is that if you mount all the network attached storage devices in Linux, crashplan can back them up, so everything on my network is backed up on a single account. Just mount them in the fstab and ask crashplan to backup the /mnt folder!

#Shares from Samba/Cifs/Windows Shares
//  /mnt/T cifs guest,uid=1000,iocharset=utf8 0 0
//      /mnt/Z cifs guest,uid=1000,iocharset=utf8 0 0

#Shares from NFS     /mnt/Music  nfs defaults    0   0    /mnt/Photos nfs defaults    0   0    /mnt/Movies nfs defaults    0   0 /mnt/Software   nfs defaults    0   0