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

Posted on 2006-05-01
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

    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.
    LVL 1

    Author Comment

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

    Thanks Again

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
    Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap ( Version 1.2 2.      Jpcap( Version 0.6 Prerequisite: 1.      GCC …
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now