rick@comspec.UUCP (Rick McCalla) (02/26/90)
I am trying to write a script that would determine what day of the week it is and depending on the day perform a specific task. I can't use a crontab entry as it will be called up by a login process. To be more specific what I am trying to do is write a script that will backup different areas of the hard drive to tape determined by what day it is run. It then has to test the exit status of the 'tar' command and email the results back to the user. Any suggestions on where to start or if anyone has a similiar script would be greatly appreciated. -- Comspec Communications Inc. | Rick McCalla ----- rick@comspec Toronto, Ontario Canada |---------------------------------- Voice : (416) 785 - 3553 | Path: uunet!mnetor!becker! Fax : (416) 785 - 3668 | comspec!rick
cpcahil@virtech.uucp (Conor P. Cahill) (02/28/90)
In article <118@comspec.UUCP> rick@comspec.UUCP (Rick McCalla) writes: >I am trying to write a script that would determine what day of the week it is >and depending on the day perform a specific task. I can't use a crontab entry >as it will be called up by a login process. To be more specific what I am >trying to do is write a script that will backup different areas of the hard >drive to tape determined by what day it is run. Don't know what system you are on, but if you have System V date(1) you can do: "date +%w" which will display the day of the week (0-sunday, etc) Otherwise you can just write a quick and dirty c program that does something like: #include <time.h> main() { struct tm * localtime(); struct tm * t; long clock; time(&clock); t = localtime(&clock); printf("%d\n", t->tm_wday); } which gets you the day of the week. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+
tkevans@fallst.UUCP (Tim Evans) (02/28/90)
In article <118@comspec.UUCP>, rick@comspec.UUCP (Rick McCalla) writes: > I am trying to write a script that would determine what day of the week it is > and depending on the day perform a specific task. set `date` DAY=$1 case "$DAY" in Mon) do some commands;; Tue) do Tuesday commands;; Wed) do Wednesday commands;; etc;; esac -- UUCP: {rutgers|ames|uunet}!mimsy!woodb!fallst!tkevans INTERNET: tkevans@fallst.uu.net Tim Evans 2201 Brookhaven Ct, Fallston, MD 21047 (301) 965-3286
bob@uxa.cso.uiuc.edu (Bob Foertsch) (03/01/90)
#!/bin/sh set `date | sed -e 's/^\(...\)........\(..\):.*/\1 \2/'` DAY=$1 HOUR=$2 now that you have the day of the week and the hour of the day you can setup case statements to do what you need. -- Bob Foertsch bob@uxf.cso.uiuc.edu Unix Systems Administrator