The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 10-21-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,428
Quote:
Originally Posted by Wotan31 View Post
I don't like loops. Why not have a cron job that runs every hour, checking for the presence of this file?
And if the cron die ?
1. add a cron job to check if the script is running, if not start the script.
2. The script should be something like:
Code:
#!/bin/sh
# Loop forever
while :
do
# Check if cron is running
  test $(ps ax | grep -c "[c]ron") -gt 0 || /etc/init.d/crond start
#Do whatever you have to do
  echo "Hello world"
# Sleep one hour
  sleep 360
done # Start over