First off, pardon my ignorance. Working on a little project last night and I notice this today.
I made a bash script that runs on a cron schedule, that works properly and does what it needs to do (as of last run, anyway). However when viewing htop, I see a ton of instances of the script in the command column, as well as portions of the script (commands within it). The script hasn't ran for hours, and these are still shown as processes.
Most of these are stale commands, ones that were issues 12+ hours ago. I know this because I can see that the command is either no longer a part of the script or containing something that has since been changed since the last run.
1.) Is this normal?
2.) Should I add something to the bash script that clears this after it's ran?
For example, right now in htop I see:
2 instances of 'sudo sh scriptname.sh'
3 instances of 'sudo sh scriptname_1.sh' (a revision, also no longer a file as it was removed)
7 instances that contain sections of the script/commands
Now, the script was not ran by root, but in htop these instances are shown as belonging to root. It was ran initially manually, by a different user on the system (sudo sh scriptname.sh), and now is ran without sudo by adding, "user ALL= NOPASSWD: /home/user/scriptname.sh" in the sudoers file. (Which seems to work as of last cron run)
So, yeah. Now what? Any tips?
I made a bash script that runs on a cron schedule, that works properly and does what it needs to do (as of last run, anyway). However when viewing htop, I see a ton of instances of the script in the command column, as well as portions of the script (commands within it). The script hasn't ran for hours, and these are still shown as processes.
Most of these are stale commands, ones that were issues 12+ hours ago. I know this because I can see that the command is either no longer a part of the script or containing something that has since been changed since the last run.
1.) Is this normal?
2.) Should I add something to the bash script that clears this after it's ran?
For example, right now in htop I see:
2 instances of 'sudo sh scriptname.sh'
3 instances of 'sudo sh scriptname_1.sh' (a revision, also no longer a file as it was removed)
7 instances that contain sections of the script/commands
Now, the script was not ran by root, but in htop these instances are shown as belonging to root. It was ran initially manually, by a different user on the system (sudo sh scriptname.sh), and now is ran without sudo by adding, "user ALL= NOPASSWD: /home/user/scriptname.sh" in the sudoers file. (Which seems to work as of last cron run)
So, yeah. Now what? Any tips?
Last edited by a moderator: