[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Sun Solaris Cron - need to split cronfile, dump, reload then after 20 minutes put back the part split off

Posted on 2006-05-01
Medium Priority
Last Modified: 2013-12-27
I have a lot of perl scripts that run from cron.  Of these the first 20 lines of the file have to be commented out before I dump cron to disk for the cold backup and then after the backup I restart cron and uncomment out these 20 lines after 20 minutes.  These perl scripts were written by a developer to  monitor some hardware to ensure the hardware is up and running.  I cannot change those scripts and am trying to figure out a way to split off these first 20 lines and reinsert them after 20 minutes.  I am working on scripting  my cold backup for oracle.  If I do not comment these lines out for the 20 minutes after the database comes up they send out about 300 bogus emails saying systems are down.
Any good suggestions would be greatly appreciated.

Question by:bkreynolds48
LVL 10

Accepted Solution

Nukfror earned 2000 total points
ID: 16578681
Then don't change the scripts, change the crontab entry that runs the scripts.  Write a "wrapper" script that is run from crontab, the script take an arguments indicating what its supposed to run as $1, it checks from flag to indicate whether its allowed to run the script it supported to or not, if so, it runs it.

Something like (very simple without testing - only to show the point):


usage() {
  echo "usage: $0 [ script1 | script2 | script3 ]"
  echo "       script1 = Run script1 which provides ...."
  echo "       script2 = Run script2 which provides ...."
  exit 1

if [ -f /tmp/DO-NOT-RUN ]; then
  exit 0

case $1 in
      script1  )  /usr/local/bin/script1 -a -b SLDK12 -X  ;;
      script2  )  /usr/local/bin/script2 -a -b SLDK13 -Z ;;
      script3  )  /usr/local/bin/script3 -X -L 123  ;;
      \? )  usage ;;

Then you have your cold backup script create and delete this /tmp/DO-NOT-RUN file (or whatever you want) as needed.  The caveat to this is you need to stay away from the obvious race condition this script presents.  You don't want crontab entries that will run the above and your cold backup script all running at same time e.g. 1pm for example.    You need to make sure you give reasonable windows between the runs as to remove the possibility of a race condition from actually happening.

Author Comment

ID: 16578715
Nukfror thanks so much - that seems like the best approach - don't know why I didn't think of that.

Thanks Again

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question