Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduling `at jobs` and dynamic output file names

Status
Not open for further replies.

AidanEnos

MIS
Dec 11, 2000
189
Running Solaris, I have a file called "pinger" that I'd like to run 4 times daily 03:00 09:00 15:00 21:00, these jobs should be launched by a script called schedule that runs just before midnight.

at 11:50pm schedule

filename = schedule
at 03:00am tomorrow pinger
at 09:00am tomorrow pinger
at 15:00am tomorrow pinger
at 21:00am tomorrow pinger
at 11:50pm tomorrow schedule

As you can see my time syntax is the issue, what EXACTLY should my syntax be for scheduling these jobs?


Since I'm asking.... pinger does a ping to a list of nodes (/etc/hosts), and outputs and appends to a file, I've just made a default file name. How can I make each job create a file name...

set FILENAME=`%m%d%t.log`

I'd like it to look like 11210300.log for the first one, help on either is greatly appreciated.
 
First question is why use at and a 'schedule' script when Solaris already provides these facilities in the form of cron? If you need more info. on cron, post back here. The basic format is:

#Crontab field order:
#minute (0-59),
#| hour (0-23),
#| | day of the month (1-31),
#| | | month of the year (1-12),
#| | | | day of the week (0-6 with 0=Sunday).
#| | | | | commands

You can probably do what you're after in terms of filenames using the filename=`date+%m%d%T`.log format.

Hope this helps - look up cron and get back with any queries.
 
As Ken said, cron is your friend ;-)

Also, you might want to look at fping ( "fping is different from ping in that you can specify any number of hosts on the command line, or specify a file containing the lists of hosts to ping. Instead of trying one host until it timeouts or replies, fping will send out a ping packet and move on to the next host in a round-robin fashion. If a host replies, it is noted and removed from the list of hosts to check. If a host does not respond within a certain time limit and/or retry limit it will be considered unreachable.
Unlike ping, fping is meant to be used in scripts and its output is easy to parse."

And if you're really interested in monitoring your systems, check out Big Brother :cool: (
One by one, the penguins steal my sanity.
 
The filename creation isn't working... and I'm trying to get root access to schedule CRON jobs, it looks like CRON is my friend - just not the variable name file creation process.

Thanks again!!!
 
In your script, try
FILENAME=`date +%m%d%H%M`.log

NB: if each file is likely to take less than 1 minute to create, you might want to do
FILENAME=`date +%m%d%H%M%S`.log

to fully differentiate the files.
One by one, the penguins steal my sanity.
 
Sorry, I think I missed out the space between date and the + in my example above. maybe that's why it didn't work?

Should be: FILENAME=`date +%m%d%T`.log

Cheers
 
The %T should give hh:mm:ss (rather than hhmmss).

Here's what I tried on my Solaris 5.5.1 box :-
[tt]
# cat test
#!/bin/sh
FILENAME=`date +%m%d%T`.log
echo $FILENAME
FILENAME=`date +%m%d%H%M%S`.log
echo $FILENAME
#
# ./test
112209:26:14.log
1122092614.log[/tt]

What happens if you run this script?
One by one, the penguins steal my sanity.
 
ayjaycee, you are officially a fatbrain :eek:)

Thanks!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top