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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SCRIPT CALLS ITSELF WITH AT

Status
Not open for further replies.

hubud

Instructor
Oct 18, 2002
123
0
0
GB
I have set up a script that calls itself using the "at" command. It seems to be working so far however when I run the script I get the following output:

copy_k2k_files.ksh.new[42]: 0: not found
commands will be executed using /bin/ksh
job 1072940400.a at Thu Jan 1 08:00:00 2004

The strange thing is that the file copy_k2k_files.ksh.new is not found. I have run this with simple test scripts and I never got this message. Also why is there a [42] appended to the file name?

The call I use in the script is:

at 08:00 tomorrow < /apps/prod/ems/scripts/copy_k2k_files.ksh.new

I was worried that because it could not find the file that it would not be able to run at the specified time, however I tested it with 2 minute intervals and it did ok.

Is there any reason why this should say this? If so how do I get rid of this?





cheers

simmo
 
Have you set your path in the script? The [42] is telling you which line in the script has an error.
 
Thanks for that bi, I've checked the file at this line number and the script is dealing with unrelated material to the file in question. In fact this part of the script is running ok.

cheers

simmo
 
Ru your script with &quot;#!/bin/ksh -p&quot;. This will ignore settings from your profile/environment when running the script and may help to hightlight the problem.

However, saying that, &quot;at&quot; should record your environment settings for when the script run again so everything should match (I always have to unset ENV else i get an error email that isn't an error...)

You could also redirect all output from your script into a debug file i.e. the first non-commented lines could be
===
exec 1>/tmp/script.out
exec 2>&1
set -x
===
which will show you exactly what your script is doing when.

If you need more help i would suggest you go to the &quot;UNIX Scripting&quot; forum here...
 
I realize that this may be a bit off topic, but is there a reason for not using cron to run the script at the same time every day? Or are you worried that the original script would take more than 24 hours to run?

Derek
 
Using cron means if I want to schedule it at a different time I have to raise a request with the sa which can take a while to get done. I have more control in this by doing it myself.

cheers

simmo
 
Pardon?

I am surprised that you have permission to run
Code:
at
, but not
Code:
cron
, as they usually come as a set.

Have you tried
Code:
crontab -e
?

Of course you have .... go beat on your S/A.
Good luck.

----------------
Derek Ludwig
derek<at>ludwig.com

 
No access to crontab which is a shame, this leads me onto another mildly related point.

When you issue the &quot;at&quot; command to run a script at a point in time does the server store the script in memory and then at the time it's due to run, run the cached script?

I noticed this today when a script ran and it did not pick up changes I had made since the time I set it to run.



cheers

simmo
 
atq

This will list all files waiting to be processed.

atrm <queueid>

will remove it from the queue.

The queue itself is not in memory, but in /var/spool/cron/atjobs.

Each time you run &quot;at&quot; it stores a new item in the queue - it does not overwite any at jobs that are effectivly the same (i.e. same time, same script, same everything) that are already queued.

 
I am very surprised you cannot create a crontab if you are allow to run
Code:
at
, at the two are sides of the same coin (please feel free to use a better similie).

And to add to the naggiman's list:

Code:
at -c
jobId

lists jobId's script, which might help diagnose your problem of not running the script you expected.

----------------
Derek Ludwig
derek<at>ludwig.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top