Can someone post the code for running a script after your logoff

garrettp

Well-Known Member
PartnerNOC
Jun 18, 2004
312
2
166
cPanel Access Level
DataCenter Provider
You could try perhaps spawning a screen session before logging out and running the script from within that screen.
 

bhd

Well-Known Member
Sep 20, 2003
149
2
166
JNB ZA
cPanel Access Level
Root Administrator
Not sure if this is what you mean but for most things, just add '&' after the command and the script will run in the background like so ./script.pl &
 

garrettp

Well-Known Member
PartnerNOC
Jun 18, 2004
312
2
166
cPanel Access Level
DataCenter Provider
The problem with sending the process to the background is when you exit the shell anything spawned in that shell (be it in the background or otherwise) will be terminated.
 

WEB-PROS

Well-Known Member
Feb 19, 2006
110
0
166
If im correct use "screen ****" then Cntrl A and Cntrl D and it will leave the screen and stay running even if you log off.
 

jrehmer

Well-Known Member
Apr 10, 2003
286
0
166
Denver, CO
Code:
nohup /bin/somecommand &
This will run the program in the background and prevent the hangup signal when logging off.
 

nxds

Well-Known Member
Jan 6, 2006
53
0
156
On Bash and Zsh you can 'disown' processes so that they don't die when you exit the shell.

For example :

Code:
% sleep 10000
ctrl-Z                                                 # send stop signal
[1]+  Stopped                 sleep 1000               # 1 is the job number
% bg                                                   # put job in background
[1]+ sleep 1000 &
% disown %sleep                                        # or disown %1
% exit
 

WEB-PROS

Well-Known Member
Feb 19, 2006
110
0
166
Yes that is virtualy screening it, putting it the background and then be able to pull it back.