LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 09: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, 10:34 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

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

Rep: Reputation: 239Reputation: 239Reputation: 239
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, 11:19 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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, 12:31 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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


Reply



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 / openSUSE 0 12-28-2004 07:16 AM
log cron job to capture errors if there are ashley75 Linux - General 1 05-21-2004 10:34 AM
sendmail opend submission ciphe Slackware 0 11-20-2003 08: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 09: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 07:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:57 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration