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.
while loop shell script
linux
The 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 PIDps -ef |(head -1; grep sleep)UID        PID  PPID  C STIME TTY          TIME CMDlambert   4062  4041  0 08:47 pts/3    00:00:00 sleep 5ps -p 4041  PID TTY          TIME CMD 4041 pts/3    00:00:00 myscript.shkill 4041