- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: finding out process id of job submitted by at ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 08:48 PM
07-31-2007 08:48 PM
finding out process id of job submitted by at command
I want to kill a looping job which was started by at command. How to find out
pid for the job. ps -ef does not show a job which matches with the submitted job's script name to find out it's process id eg a job has been submitted using following command:
at -f /scripts/myjob.sh now
it prints message similar to following:
job 1185957711.a at Wed Aug 1 11:41:51 2007
but I can not find out pid for running job.
Kindly suggest. Thanking you. RAKESH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 09:15 PM
07-31-2007 09:15 PM
Re: finding out process id of job submitted by at command
since you now when you started the at job and since it is still running, you can easily retrieve the PID of the parent by looking into /var/adm/cron/log
Once you have "parsed" it from there you can look up your proc table by parsing all those procs whose PPID is identical to the PID in the cron log.
If those in turn have spawned other procs themselves it could be a bit nested and maybe the hierarchy switch of XPG4 ps would help (e.g. UNIX95= ps -H ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 09:15 PM
07-31-2007 09:15 PM
Re: finding out process id of job submitted by at command
since you know when you started the at job and since it is still running, you can easily retrieve the PID of the parent by looking into /var/adm/cron/log
Once you have "parsed" it from there you can look up your proc table by parsing all those procs whose PPID is identical to the PID in the cron log.
If those in turn have spawned other procs themselves it could be a bit nested and maybe the hierarchy switch of XPG4 ps would help (e.g. UNIX95= ps -H ...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 09:17 PM
07-31-2007 09:17 PM
Re: finding out process id of job submitted by at command
Must have accidentally resubmitted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 10:32 PM
07-31-2007 10:32 PM
Re: finding out process id of job submitted by at command
Thanks for your reply. It helped in finding out the process IDs of the jobs submitted by
at command.
I am executing the following script at command:
#!/bin/sh
mm=0
while test $mm -le 600
do
date >> /tmp/dbc6.log
ps -ef | grep dbcheck | grep -v grep >> /tmp/dbc6.log
mm=$mm+1
sleep 60
done
mailx -s "DBCHECK LOG" rakesh@kuc01.kuniv.edu.kw < /tmp/dbc6.log
#
But /tmp/dbc6.log file does not contain the output of ps command while executing after submitting by at command.
If I execute the script directly from my terminal, the output from ps -ef command
goes to /tmp/dbc6.log.
Why it is so & what can be done to get the
output in this file after submitting script through at command?
Thanking you once again.
Best regards, RAKESH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 10:46 PM
07-31-2007 10:46 PM
Re: finding out process id of job submitted by at command
#!/bin/sh
mm=0
while test $mm -le 600
do
date >> /tmp/dbc6.log
INIX95=1 ps -f -C dbcheck >> /tmp/dbc6.log
let mm=$mm+1
sleep 60
done
mailx -s "DBCHECK LOG" rakesh@kuc01.kuniv.edu.kw < /tmp/dbc6.log
The arithmetic statement: mm=$mm+1 requires one of these formats:
let mm=$mm+1
mm=$(($mm + 1))
mm=$(expr $mm + 1)
The statement in your original script: mm=$mm+1 produces:
echo $mm
0+1
and not the next higher number. The use of ps -C eliminates numerous errors in selecting processes because they have your search string imbedded somewhere. ps -C is 100% reliable as it looks at the process table rather than grep.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 10:50 PM
07-31-2007 10:50 PM
Re: finding out process id of job submitted by at command
UNIX95=1 ps -f -C dbcheck >> /tmp/dbc6.log
The man page explains the special options -C -H -o (and others) that are activated in the XPG3 environment, designated by the temporary use of the UNIX95 variable.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 10:53 PM
07-31-2007 10:53 PM
Re: finding out process id of job submitted by at command
Maybe in your current shell, where things work, you have already declared it as integer?
In the script I would suggest
typeset -i mm=0
...
((m+=1)) # instead of mm=$mm+1
Also note, that cron as well as at and batch jobs are executed with a minimalistic environment that might deviate considerably from the one in your current shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2007 10:56 PM
07-31-2007 10:56 PM
Re: finding out process id of job submitted by at command
Bill must have posted while I was still filling in the form's textarea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 12:15 AM
08-01-2007 12:15 AM
Re: finding out process id of job submitted by at command
mm variable. I will check it more carefully by displaying the value of mm after inrementing it.
The main reason for asking the question was
that when I execute the :
ps -ef | grep dbcheck | grep -v grep >> /tmp/dbc6.log
Command (kindly consider the second line also as first line ... while writing this it automatically is wrapping it to second
line here) does not produce any output in
/tmp/dbc6.log file when the procedure is executed using at command but it produces the proper output if same script is execued
on terminal directly. What is the reason for this & how to handle the situation to
get the output in the file after executing
the script using at command?
Thanking you once again.
Best regards, RAKESH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 12:42 AM
08-01-2007 12:42 AM
Re: finding out process id of job submitted by at command
This is incorrect. at(1) and batch(1) jobs are invoked with your current environment, umask and directory.
They don't have aliases or functions. Of course scripts should be using any of these that are not defined explictly.
>Command does not produce any output in
Since your environment should be available in at(1) jobs, a wrong PATH doesn't explain it.
But it wouldn't hurt to use this to check:
whence ps
whence grep
Also, have you used Bill's suggestion for the ps(1) command?
>Ralph: Sorry, for my redundant information.
Don't be. Your ((m+=1)) solution was better than Bill's. ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 02:58 AM
08-01-2007 02:58 AM
Re: finding out process id of job submitted by at command
Of course is Dennis correct, which in this case I even could have verified without any reference to the man page by simply issueing
# at -d
As for your proc tab grep issue,
have you tried to use the XPG4 -C option that Bill suggested and discarding all the obsolete "grep -v grep" stuff?
If the command's base name without any args really is "dbcheck" then a "UNIX95= ps -C dbcheck" should produce valid output.
Since I don't have this proc on my box lets take another ubiquitious proc as example:
$ UNIX95= ps -C httpd -o pid,ppid,args
PID PPID COMMAND
2104 1 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start
2106 2104 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start
2115 2104 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start
2113 2104 /opt/hpws/apache/bin/httpd -d /opt/hpws/apache -k start
As you can see, it doesn't even matter what bunch of args is following.
The -C option is a really fail-safe as opposed to obsolete ps grep chicanery.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 05:16 AM
08-01-2007 05:16 AM
Re: finding out process id of job submitted by at command
echo $$ > /
which should place the script's current process id in the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 07:39 PM
08-02-2007 07:39 PM
Re: finding out process id of job submitted by at command
Thanks for replies. These have been very useful. Now I know how to find process Id for a job submitted through at command &
also how to save its own pid in a file for
a process. Also, there was a mistake in my
script for adding 1 to a variable for which
various useful suggestions were provided. I checked one of my old scripts where I was
using:
mm=`expr $mm + 1`
I used this now & it works fine.
My actual problem was that some process was
executing dbcheck program (used for Data
Protector's Internal DB) & I was unable to
figure out which program it could be. With some more modifications to my script I managed to find out that HP Openview Operations (OVO) does this. This is causing the failure of backing up DP's Internal DB.
Anyway, now we know who is causing the problem so now we can take proper action.
Thanking you all once again.
Best regards, RAKESH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2007 08:00 PM
08-02-2007 08:00 PM
Re: finding out process id of job submitted by at command
through at command.
2. Some new fags (eg UNIX95) available.
3. Various ways of incrementing counter
a counter variable.