LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script running in background disappeared (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-running-in-background-disappeared-4175711606/)

awaismalik 05-03-2022 12:55 AM

bash script running in background disappeared
 
Hi,
I set the script to run in background using
/bin/bash /home/user/script.sh Argument &

the script appeared in ps aux
root 1189438 0.0 0.0 12724 3060 pts/0 S 12:39 0:00 /bin/bash /home/user/script.sh Argument


and now today i dont see the script listed or running anymore in ps aux output while niether PC nor any service was restarted.i dont understand how process got killed or stop ?. how should i look into this.

ondoho 05-03-2022 01:56 AM

Quote:

Originally Posted by awaismalik (Post 6350398)
Hi,
I set the script to run in background using
/bin/bash /home/user/script.sh Argument &

the script appeared in ps aux
root 1189438 0.0 0.0 12724 3060 pts/0 S 12:39 0:00 /bin/bash /home/user/script.sh Argument


and now today i dont see the script listed or running anymore in ps aux output while niether PC nor any service was restarted.i dont understand how process got killed or stop ?. how should i look into this.

Maybe the script terminated.
Would be nice to see the actual script.

pan64 05-03-2022 03:57 AM

you cannot check a process which is already terminated, but you can add some logging to that script to see how does it work (next time).

michaelk 05-03-2022 05:05 AM

Not enough information. In addition to the above.

Although your script is running in the background it is still attached to its parent process. A common mistake is to close the terminal or if it is a remote connection to close the session. Using nohup or using screen will detach the process.

TB0ne 05-03-2022 09:32 AM

Quote:

Originally Posted by awaismalik (Post 6350398)
Hi,
I set the script to run in background using
/bin/bash /home/user/script.sh Argument &

the script appeared in ps aux
root 1189438 0.0 0.0 12724 3060 pts/0 S 12:39 0:00 /bin/bash /home/user/script.sh Argument

and now today i dont see the script listed or running anymore in ps aux output while niether PC nor any service was restarted.i dont understand how process got killed or stop ?. how should i look into this.

Unless you started it with "nohup", as soon as you closed that terminal window, that script closed. So if you rebooted your PC (or even just logged out), it's gone. As said, you're not showing us the script or giving us any details.


All times are GMT -5. The time now is 02:44 AM.