OT: Cron question
Many of your questions may have already been answered in earlier discussions or in the FAQ. The search results page will indicate current discussions as well as past list serves, articles, and papers.
alvin at Maggie.Linux-Consulting.com alvin at Maggie.Linux-Consulting.comFri Feb 15 16:40:15 PST 2002
- Previous message: OT: Cron question
- Next message: comp.distributed -- Usenet discussion group passesand exists...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
hi ya maybe i am misunderstanding... if days-of-month(date) < 7... than run job B otherwise job A crontab -e ... # 1:01am first 7 days of the month 1 1 1-7 * * /usr/local/scripts/JobB -job dothis # # 2:15am from 8th - 31st of the month 15 02 8-31 * * /usr/local/scripts/JobA -job somethingElse have fun alvin http://www.Linux-Backup.net ... lots'o backup scripts ... # # format of fields # # MIN HOUR DAY MONTH DAYOFWEEK COMMAND # --- ---- --- ----- --------- ----------- ... # Sat at 1:01am # 1 01 * * 6 weekly backup on sat # Sun at 2:01am # 1 02 * * 0 full backup on su On Sat, 16 Feb 2002, [iso-8859-1] Jakob Østergaard wrote: > On Fri, Feb 15, 2002 at 06:15:46PM -0600, gj wrote: > > use cron as a front to a script which uses formatted output from date to > > > > check the day of the week, if Fri > > check day of the month, if <=7 > > execute job B > > otherwise > > execute job A > > > > This could be implemented in Bourne shell script in a few minutes. > > > > Cron doesn't really have any flow control capabilities. Scripting is > > the only way to go. > ... > > Thanks - ok, several people have suggested this, and in fact I did the script > almost immediately after the first suggestion. Just for the record, here goes > a script to make the Amanda backup system run one backup set every first friday > in the month, and another set all other days. > > It is assumed that cron runs the script as root, and with the arguments "check" > early in the day (to see if the right tape is available), and "backup" later on > for the real backup. > > Use and abuse as you see fit :) > > ---------------------------8<------------------ > #!/bin/bash > # > # This script will either check tapes or perform > # a backup of some particular backup set, depending > # on the date, and on the argument given: > # > # argument "check" causes the script to check for tapes > # argument "backup" causes the script to run the backup > # > # the first friday in the month, the script will use "FullSet" > # on all other days it will use "DailySet" > # > DAILYSET="DailySet" > FULLSET="FullSet" > > # 0 is sunday, 0-6 > DAYOFWEEK=`date +%w` > > # 1-31 > DAYOFMONTH=`date +%d` > > # Is this a friday ? > if [ $DAYOFWEEK -eq 5 ]; then > # Is this the first week of the month ? > if [ $DAYOFMONTH -lt 8 ]; then > USESET=$FULLSET > else > USESET=$DAILYSET > fi > else > USESET=$DAILYSET > fi > > # Check args > case "$1" in > check) > COMMAND="/usr/sbin/amcheck -m $USESET" > ;; > backup) > COMMAND="/usr/sbin/amdump $USESET && (/usr/sbin/amverify $USESET &> /dev/null)" > ;; > test) > COMMAND="echo \"Will run backup set \\\"$USESET\\\"\"" > ;; > *) > echo "Must use either check, backup, or test as argument" > exit 1 > esac > > # echo "$COMMAND" > su amanda -c "$COMMAND" > ---------------------------8<------------------ > > > -- > ................................................................ > : jakob at unthought.net : And I see the elder races, : > :.........................: putrid forms of man : > : Jakob Østergaard : See him rise and claim the earth, : > : OZ9ABN : his downfall is at hand. : > :.........................:............{Konkhra}...............: > _______________________________________________ > Beowulf mailing list, Beowulf at beowulf.org > To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf >
- Previous message: OT: Cron question
- Next message: comp.distributed -- Usenet discussion group passesand exists...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Beowulf mailing list
