Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have started a Perl script from the terminal that runs in the background:

>perl &

If I logout, will it stop my script from running?


share|improve this question
up vote 4 down vote accepted

Yes, this is dead easy to test. Write a perl script that appends the date to a file every minute, and run it in the background. Log out, wait 5 minutes, log in, check for 5 entries corresponding to the times you are logged out. To get it working in future (too late if it's already running) use nohup as explained in another answer. You can background a foreground script after you start it (CTRL-Z) but you can only nohup it at execution

share|improve this answer
Thanks for the suggestion but the thing is my script has been running for a long time and I did not want to stop to test it. I had no idea it was going to run this long but I just ran some calculations and this looks to be about a 90hr job! – Allen Liu Mar 15 '12 at 22:46
If you have any doubt, then stick to a) password protected screensaver rather than logging out if security is the issue, or b) turn on fast user switching if someone else needing to use the computer is the issue - neither of these will affect it. – stuffe Mar 15 '12 at 22:51

In addition to @stuffe's answer, if you are logged in via ssh and run your command, it will die when you close the connection. So, if you were at home and ssh'ed into your office workstation and executed your perl & command, it would die when you exit'ed from the ssh connection.

To avoid this problem, you'll want to use the nohup command, which dates back to the teletype days and stands for "no hangup" --- essentially it causes the command to ignore the POSIX HUP (hangup) signal. It is used as:

nohup perl &

This will keep running on your office workstation even after you have disconnected/logged out from your home machine.

share|improve this answer
indeed, nohup is the answer! – stuffe Mar 16 '12 at 0:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.