I have a script that needs to be run on background, if I run the same script on foreground, the script runs good and it wont stop until we manually interrupt (ctrl^c).
I am sure that the below command runs the script in background.
sudo -u webs ./spagent_L1 &
Once the above command is executed it will give the job number and the process number.
[1] 10118
And immediately after that if i press enter two times, the job gets stopped.
[1]+ Stopped sudo -u webs ./spagent_L1
if I check the jobs running in background it shows that the job has been stopped.
$> jobs
[1]+ Stopped sudo -u webs ./spagent_L1
Whereas if I check for process running, it shows like the above mentioned script is running.
$> ps -eo user,ppid,pid,cmd,state | grep -i spagent
root 10118 9383 0 05:42 pts/1 00:00:00 sudo -u webs ./spagent_L1 T
ape 10122 3983 0 05:42 pts/1 00:00:00 grep -i spagent R
Unless I kill the process 10118 the jobs command shows the output that the process is stopped. Once the process is killed, the jobs command doesn't return anything.
So, does the above output mean if the process is still running? Could anyone please help me understand what is happening up there. and how to run the script in background without getting it stopped.
Thanks in advance.
ps -ef | grep -i spagent
$> ps -eo | grep web ERROR: Format specification must follow -o. ********* simple selection ********* ********* selection by list ********* -A all processes -C by command name -N negate selection -G by real group ID (supports names) -a all w/ tty except session leaders -U by real user ID (supports names) -d all except session leaders -g by session OR by effective group name -e all processes -p by process ID
ps-ef
is passed togrep -i spagent
nohup sudo -u webs ./spagent_L1 > some_log_file 2>&1 &
this will print the output to the file and then check it to see if you find the issue.nohup
is a linux tool to run processes immune to hangups (even after the shell executed them is closed)