1837095 Members
2351 Online
110112 Solutions
New Discussion

at -f now

 
SOLVED
Go to solution
Dave La Mar
Honored Contributor

at -f now

I have two scripts in the same directory.
From a mainframe, or manually, I call a script that
performs:
at -f /path/filename now
at -f /path/filename2 now
Filename executes, filename2 does not.
Executing the calling script manually, I see an at job and job id for both, but only filname executes.
I can manually execute filename2.
I think I need another set of eyes.
Thanks for any input.
dl
"I'm not dumb. I just have a command of thoroughly useless information."
12 REPLIES 12
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: at -f now

Hi:

This almost always is a result of the sparse environment of cron/at. You probably are missing either a PATH or some other needed environment variable that is setup when you run interactively but not from at.
If it ain't broke, I can fix that.
Dave La Mar
Honored Contributor

Re: at -f now

Clay -
I sourced in the .profile as suggested but still only one of the two actually runs.

Still got blinders on....
dl
"I'm not dumb. I just have a command of thoroughly useless information."
harry d brown jr
Honored Contributor

Re: at -f now

Like Clay said, you don't have enough in your cron/at environment to get the job done.

To the script filename2 add this line near the top:

env |sort > /tmp/env4filename2

then try the "at" command again.

then do this from your command line:

env |sort > /tmp/env4me

then do a :

diff -w /tmp/env4me /tmp/env4filename2 | more

Path variables are the most important, but others might be necessary.

live free or die
harry

Live Free or Die
S.K. Chan
Honored Contributor

Re: at -f now

The 'filename' and 'filename2' are files that simply has the script path right, not the script itself ?
Krishna Prasad
Trusted Contributor

Re: at -f now

You can also log out information during the script to a log file. This way you can see that the script actually starts and what steps it gets to. I usally do something like echo "Starting script2 at `date`" >> $LOG

echo "Starting step1 for script2" >> $LOG

check return status maybe then echo success or failure.

if [ $? = 0 ]
then
echo "Step1 successful." >> $LOG
else
echo "Step1 failed". >> $LOG
fi

I hope this helps

Positive Results requires Positive Thinking
A. Clay Stephenson
Acclaimed Contributor

Re: at -f now

Hi Dave:

I did not say source your .profile. That is almost always a bad idea unless you have all the interactive or tty stuff if'ed out.
If it ain't broke, I can fix that.
Darrell Allen
Honored Contributor

Re: at -f now

Hi Dave,

When you say filename2 doesn't run, do you mean the at job doesn't run? Or do you mean the at job does run but filename2 doesn't?

Check /var/adm/cron/log to verify the at job ran. You should see something like:
> CMD: 1012939331.a
> root 329 a Tue Feb 5 15:02:11 EST 2002
< root 329 a Tue Feb 5 15:02:11 EST 2002

Do you redirect the output from filename2? If not, do you get a mail message from "at" for filename2? If you do redirect the output, does the output file get created / updated?

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Dave La Mar
Honored Contributor

Re: at -f now

The env differences were variables I was setting in the script that performs the
at -f /../.. now.
I have hardcoded the entire path instead of using variables and still no execution.
I have enough checks and logging in the script being called to know it is not running or has not run.
Quite simply - (sure easy for you to say)

SCRIPT_AT performs
at -f /path_to/script_1 now
at -f /path_to/script_2 now

Issue both commands from the
command line and only script_1
runs.
Issue /path_to/sctipt_2 from the command line and it executes.

Bridle's getting tight....
d
"I'm not dumb. I just have a command of thoroughly useless information."
Dave La Mar
Honored Contributor

Re: at -f now

Well,
The machine does not lie.
It show a job number amd time,
but I never saw the job running.
I put another catch to a log at the top of the script and found is is being called.
Now I need to debug why it dies before writing to any other log file when it runs standalone fine.

Thanks for all the input.

dl
"I'm not dumb. I just have a command of thoroughly useless information."
James R. Ferguson
Acclaimed Contributor

Re: at -f now

Hi Dave:

Do you have 'read' statements (from stdin) in your script? If so, and you are executing the script unconditionally (i.e. without testing whether or not it is interacive), you may get unexpected actions. Is this the case?

Regards!

...JRF...
Dave La Mar
Honored Contributor

Re: at -f now

James -
Nothing interactive. Thanks for the suggestion.
I am still stepping through each line of code to see where it may be exiting or failing when not run from the command line.
dl
"I'm not dumb. I just have a command of thoroughly useless information."
Dave La Mar
Honored Contributor

Re: at -f now

Found the problem in a variable in the script to be executed. It was picking up the shell from the at command for the variable value.
Hardcoded it in the script2 and all is well.
Thanks for all the input.
dl
"I'm not dumb. I just have a command of thoroughly useless information."