LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Capture at job number upon submission (http://www.linuxquestions.org/questions/programming-9/capture-at-job-number-upon-submission-423176/)

AmyBVT 03-09-2006 09:54 AM

Capture at job number upon submission
 
I've got a shell script that submits a subjob to atd. This subjob could potentially take a long time. If it is taking more than 15 minutes, the script moves on and performs the action in another (less desirable) way and the at job should be cancelled or killed. Is there a way to capture the at job number that is submitted? If for some reason the atd daemon is down or hung, I want to be able to remove the at job I submitted.

If I can capture this job number, I can be assured I atrm the right job number. There are obviously other work arounds, but it is much clearer if I could just capture this job number during submission.

Thanks!
Amy

bigearsbilly 03-09-2006 10:34 AM

?
you mean if the job hasn't started running within 15 minutes, i.e. still on the queue?

bigearsbilly 03-09-2006 10:38 AM

Code:

billym.>set -- $(echo ls | batch 2>&1)
billym.>echo job is $8               
job is 1141922121.b

note: will screw your $* parameters

unSpawn 03-09-2006 11:19 AM

Is there a way to capture the at job number that is submitted?
jobnr=($(at -f commandfile timespec 2>/dev/null)); [ "${#jobnr[@]}" = "5" ] && jobnr=${jobnr[1]}
Could do with some more tests but should work.

chrism01 03-10-2006 12:31 AM

You could just use
nohup jobname &
then use
echo $&
to get jobnum & process id


All times are GMT -5. The time now is 04:32 AM.