LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-09-2006, 10:54 AM   #1
AmyBVT
LQ Newbie
 
Registered: Jan 2006
Posts: 1

Rep: Reputation: 0
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
 
Old 03-09-2006, 11:34 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,298

Rep: Reputation: 175Reputation: 175
?
you mean if the job hasn't started running within 15 minutes, i.e. still on the queue?
 
Old 03-09-2006, 11:38 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,298

Rep: Reputation: 175Reputation: 175
Code:
billym.>set -- $(echo ls | batch 2>&1)
billym.>echo job is $8                
job is 1141922121.b
note: will screw your $* parameters
 
Old 03-09-2006, 12:19 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,561
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
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.
 
Old 03-10-2006, 01:31 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
You could just use
nohup jobname &
then use
echo $&
to get jobnum & process id
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multipart form submission encoding problem in Suse jodi Suse/Novell 0 12-28-2004 08:16 AM
log cron job to capture errors if there are ashley75 Linux - General 1 05-21-2004 11:34 AM
sendmail opend submission ciphe Slackware 0 11-20-2003 09:12 AM
why there is a need for minor number and major number for monitor/keyboard in pc? tripathi Solaris / OpenSolaris 1 11-07-2003 10:36 AM
Capture support for dvd and video capture in linux is it even going to be real ever? maximalred Linux - Distributions 3 07-06-2003 08:29 PM


All times are GMT -5. The time now is 05:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration