Process control in linux
|
|
shanky | Date: Wednesday, 2014-05-28, 4:50 PM | Message # 1 |
Lieutenant
Group: Administrators
Messages: 46
Awards: 0
Reputation: 104
Status: Offline
| On behalf of a user: Hello,
I need to include a functionality in the scripts whichallows restart ability .
The requirement is that in case of any error or failure thescript would come out with an exit code.
And when the script is run again with correct data, itshould start from the point where it stopped the last time.
Can someone please share any knowledge on such afunctionality using UNIX shell scripting?
Thanks & regards, Preeta
s.k.bhagat
|
|
|
|
shanky | Date: Wednesday, 2014-05-28, 4:51 PM | Message # 2 |
Lieutenant
Group: Administrators
Messages: 46
Awards: 0
Reputation: 104
Status: Offline
| HI Preeta
Try below code:
#!/usr/bin/ksh
print"If error occured here!!"; pid=$(ps-ef|grep -i pause|grep -v grep|cut -d " " -f 3); kill -STOP$pid;
# will pause the process
print "continueing after error from here!!";
Regards Shankar Kumar Bhagat
s.k.bhagat
|
|
|
|
shanky | Date: Wednesday, 2014-05-28, 5:26 PM | Message # 3 |
Lieutenant
Group: Administrators
Messages: 46
Awards: 0
Reputation: 104
Status: Offline
| Later, get the process id of script by: pid=ps -ef|grep -i <scriptname>|grep -v grep|cut -d " " -f 3
And, you can resume the same script/process from where it had stopped by using below commad kill -CONT $pid
s.k.bhagat
|
|
|
|