System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a log for commands ran via 'at now'

Raymond E. Lilly
Frequent Advisor

Is there a log for commands ran via 'at now'

HPUX v3

Is there a log similar to /var/adm/cron/log for commands ran by 'at now'?

For example, is there a way to find the
command line listed below after the command runs?

at now {return}
/home/my_shell_script.sh yes 4711 {return}
{CTRL D}

Thanks,
Ray
10 REPLIES
Jose Mosquera
Honored Contributor

Re: Is there a log for commands ran via 'at now'

Hi,

#at -l

You will see output such as:
job 8745156.a at wed Sep 17 11:00:00 2010

Rgds
Jose Mosquera
Honored Contributor

Re: Is there a log for commands ran via 'at now'

Ooooops, previous post is just for tasks pending to run! Foget it!
Matti_Kurkela
Honored Contributor

Re: Is there a log for commands ran via 'at now'

In HP-UX, the cron daemon runs both cron and at jobs. So the command line should be visible in /var/adm/cron/log.

MK
MK
Raymond E. Lilly
Frequent Advisor

Re: Is there a log for commands ran via 'at now'

I did a test and all that gets into the /var/adm/cron/log is the job identifier in the form jobnumber.queue, CMD: 1296664522.a in this case. Which is not very helpful. Any other thoughts?

For example:

# at now +2 minute
ls -lt > ./somefile.txt
warning: commands will be executed using /usr/bin/sh
job 1296664522.a at Wed Feb 2 17:35:22 2011


tail /var/adm/cron/log
< root 9766 c Wed Feb 2 17:35:00 MET 2011
> CMD: 1296664522.a
> root 9785 a Wed Feb 2 17:35:22 MET 2011
< root 9785 a Wed Feb 2 17:35:22 MET 2011
Pete Randall
Outstanding Contributor

Re: Is there a log for commands ran via 'at now'

I would think you should have the command you're running do it's own logging. Then you can verify that it ran by looking at cronlog if need be, but you'll have the detail you need in your own log file. The system isn't going to do this automatically for you.


Pete

Pete
Jeff_Traigle
Honored Contributor

Re: Is there a log for commands ran via 'at now'

As you see, at jobs are simply scripts run by cron. That's all that is going to show up in the cron log. It's no different than a script you schedule in cron being identified in the log. You don't know what the exact commands within the scripts are for those either.
--
Jeff Traigle
Raymond E. Lilly
Frequent Advisor

Re: Is there a log for commands ran via 'at now'

Hi Jeff, I disagree with the last statement about how 'at' jobs and 'cron' jobs show in the log.

cron entries show the entire command line:
> CMD: /opt/sfm/bin/restart_sfm.sh
> root 12573 c Wed Feb 2 04:05:00 MET 2011
< root 12573 c Wed Feb 2 04:05:03 MET 2011

'at now' shows only the the job identifier:
> CMD: 1296664522.a
> root 9785 a Wed Feb 2 17:35:22 MET 2011
< root 9785 a Wed Feb 2 17:35:22 MET 2011

Makes me wonder if there is a configuration missing somewhere.
Pete Randall
Outstanding Contributor

Re: Is there a log for commands ran via 'at now'

Spending a little time with the man pages for at might prove fruitful - particularly the "How Jobs Are Processed" section:

. . .
An at or batch job consists of a two-part script stored in /var/spool/cron/atjobs that can be executed by the POSIX shell. The first part sets up the environment to match the environment when the at or batch command was issued. The second part consists of the commands that you entered.
. . .

That's how at works and that's why all you see is the job-id. As I said before, I'm not sure what else you wish to see, but if you alter the command that you are at'ing to do it's own logging then you can log anything you wish.


Pete

Pete
Dennis Handly
Acclaimed Contributor

Re: Is there a log for commands ran via 'at now'

>Any other thoughts?

Always use crontab vs at(1)?
at(1) does have a benefit of saving your environment but not your aliases.
Raymond E. Lilly
Frequent Advisor

Re: Is there a log for commands ran via 'at now'

I started with the man pages and did some testing. The line Pete mentioned "An at or batch job consists of a two-part script stored in /var/spool/cron/atjobs that can be executed by the POSIX shell." led me to believe the script would be there for me to review. However, this script is only available while it is pending. It is gone as soon as the scheduler runs it.

We are a 24/7 shop with 3 administrators that 'follow the sun'. Sometimes I find evidence that one of my counterparts ran something with 'at now'. I hoped there was an easy way to find the entire command line without the need to change how they work.

Pete's suggestion is the right way to go, but they won't do it. Same goes for using crontab.

One suggestion I got was to wrap a script around the 'at' command and have it do the logging. Sounds feasible, but probably not worth the effort in this case.

Thanks for all the feedback and suggestions!
Ray