Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab

Status
Not open for further replies.

AIXFinder

IS-IT--Management
Joined
Jan 4, 2007
Messages
97
Location
US
I want to set up a crontab to get e-mail from nodes daily.
The e-mail will contain:

fget_config -vA
lspv
lsconf

However, I just found that lsconf can hang due to some errors like below:

0516-1201 lsvg: Warning: Volume group prod3vg is locked. This command
will continue retries until lock is free. If lock is inadvertent
and needs to be removed, execute 'chvg -u prod3vg'.

If there are any errors like aforementioned and lsconf commands are just hanging, then I want to receive e-mail for the outputs from the first two commands (fget_config –vA and lspv) and the output (which is only up to the point where it stops due to the error) from lsconf. The reason is that I don’t want to let the crontab hung w/o sending any messages.

How do you make a cron for this scenario?

Thx much
 
Something along these lines
Code:
mfile=/tmp/mfile.$$ 
#suitable temporary name

fget_config -vA > $mfile 
# add output of fget_config -vA 

lspv >> $mfile 
# append output of lspv

lsconf >> $mfile & 
# start lsconf in the background

sleep 300 
# give it five minutes - experiment here

jobid=$(jobs -p) 
# set jobid ti id of any background process

[[ -z "$jobid" ]] || kill $jobid 
# kill the process if still running

mail -s "configuration of $(uname -n)" me@myserver < /tmp/mfile.$$ 
# send back a copy of the file

rm /tmp/mfile.$$ 
# A tidy box is a happy box!

Ceci n'est pas une signature
Columb Healy
 
>> jobid=$(jobs -p)
# set jobid ti id of any background process

[[ -z "$jobid" ]] || kill $jobid
# kill the process if still running

Is it going to kill ONLY the job ID in the cron, or kill all other job IDs in pending?

thx
 
It will only kill lsconf process (and its child processes)

jobs -p shows process group ID of all (background) jobs, in this case it is the process ID of the command from above:

lsconf >> $mfile &



HTH,

p5wizard
 
jobs -p should only return background jobs associated with the relevant session. If you want you can leave it out and put
Code:
echo jobs -p returns $(jobs -p) >> /tmp/mfile.$$
[[ -z "$jobid" ]] || ps -ef | grep $jobid >> /tmp/mfile.$$

For the first few runs you can kill off any lsconf processes by hand in the morning and check, using the code above, that the script would have worked as expected. Once you are happy that jobs -p is returning what you want you can revert to the code above.

Ceci n'est pas une signature
Columb Healy
 
AIXFinder said:
0516-1201 lsvg: Warning: Volume group prod3vg is locked. This command
will continue retries until lock is free.
If lock is inadvertent
and needs to be removed, execute 'chvg -u prod3vg'.

If there are any errors like aforementioned and lsconf commands are just hanging, then I want to receive e-mail for the outputs from the first two commands (fget_config –vA and lspv) and the output (which is only up to the point where it stops due to the error) from lsconf. The reason is that I don’t want to let the crontab hung w/o sending any messages.

Note that under normal conditions, eventually a VG lock should be released, and the commands issued by lsconf keep on retrying until the lock is released. So give lsconf plenty of time to run its course. Just 5 minutes seems to me rather short. I'd give it 15 mins at least... As Columb stated, you've got to experiment a bit with the sleep period.


HTH,

p5wizard
 
Before using the -u flag, make sure that the volume group is not being used by another LVM command."

so, how do you check this?
 
for a start:

ps -ef|egrep 'vg|pv|lv'


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top