I have written a Linux (bash) shell script using while loop and I kept sleep command to execute the script for every 60 sec and the output is redirected to other file. After few hours I stopped the script and it doesn't stop executing and I deleted the script still it is running and the output file is updated every 60 seconds. I could see sleep command in the process running by Linux. I tried to kill the PID of sleep using kill -9 PID command. No use. It is in my production server.can some one help out. How should we stop the execution of script.
closed as unclear what you're asking by jasonwryan, Archemar, Jakuje, dr01, Stephen Kitt Jan 7 '16 at 9:40
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
sleep command is invoked by your script. If you kill the
sleep command the script advances to the next command. You need to look at the parent pid (PPID) of the
sleep command using
ps for instance. Then look for the corresponding parent pid (PPID) and kill the process that belongs to that PID
ps -ef |(head -1; grep sleep) UID PID PPID C STIME TTY TIME CMD lambert 4062 4041 0 08:47 pts/3 00:00:00 sleep 5 ps -p 4041 PID TTY TIME CMD 4041 pts/3 00:00:00 myscript.sh kill 4041
It may be running in the background:
$ jobs + Running sleep 100 & $ kill %1 + Terminated sleep 100
You can also use pkill and pgrep
Use killall to stop all of the instances.
Try to use 'ps -ef | grep your script name' to find the pid of your task. Then use 'kill -9 your pid' to kill the process.