Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Below is my script what i am trying but it is not working because timeout will kill the process after 20 minutes and executes further commands. I don't want to kill the process it has go to execute further commands.
#!/bin/sh
timeout 20m sh /dv4/delete-dv4.sh
PID=`echo $$`
if ps -p $PID > /dev/null
then
echo "$PID is running"
fi
timeout 20m sh /dv4/delete-dv4.sh
PID=`echo $$`
if ps -p $PID > /dev/null
then
echo "$PID is still running"
fi
kill -s 15 $PID
1. My requirement is sh /dv4/delete-dv4.sh has to be run up to 20 minutes and count time in X varable
3. After 20 minutes i need to send My process running
4.After 20 minutes again i need to be start sh /dv4/delete-dv4.sh and start count time from where it stopped earlier (In x Variable)
5. After 20 minutes i need to send My process is still running
6 If count time reached 40 minutues
7 kill the process
Below is my script what i am trying but it is not working because timeout will kill the process after 20 minutes and executes further commands. I don't want to kill the process it has go to execute further commands.
#!/bin/sh
timeout 20m sh /dv4/delete-dv4.sh
PID=`echo $$`
if ps -p $PID > /dev/null
then
echo "$PID is running"
fi
timeout 20m sh /dv4/delete-dv4.sh
PID=`echo $$`
if ps -p $PID > /dev/null
then
echo "$PID is still running"
fi
kill -s 15 $PID
1. My requirement is sh /dv4/delete-dv4.sh has to be run up to 20 minutes and count time in X varable
3. After 20 minutes i need to send My process running
4.After 20 minutes again i need to be start sh /dv4/delete-dv4.sh and start count time from where it stopped earlier (In x Variable)
5. After 20 minutes i need to send My process is still running
6 If count time reached 40 minutues
7 kill the process
It is always good to put your script in code tags as it makes it easy to read. In the script I don't see that you are killing the script the first time. So where the question comes to start it again? Are you saying that it should run for 20 minutes, send the status, kill the process and then start the same process again with 20 minutes timer, at the end of timer send the status, kill the process and shouldn't start again?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.