Hey All, wrote this script to confuse my girlfriend when she is using my computer. The only trouble is that if the terminal gets closed the script stops to execute. It currently executes in the background but how can I make it run in the background but not in a terminal?

(sleep 5; say "Hello Girlfriend")&
  • So where do you ultimately want to show her the message? – John T Feb 10 '10 at 5:14
  • 1
    If it's not running in a terminal, how do you expect to see the output? – pavium Feb 10 '10 at 5:15
  • 4
    @John T and pavium: the say command on Mac OS X is a voice to text to voice command. Ie: the command will read the text and play it on the speakers. – sixtyfootersdude Feb 10 '10 at 5:21
  • I suppose she gets confused because it says "girl frinde" instead of "girl friend"? – Nathaniel Feb 10 '10 at 5:31
  • Actually, I did notice the word 'say', but not being a Mac person I didn't catch on. If anything I might have thought of the say function in Perl 5.10 – pavium Feb 10 '10 at 6:09

You could schedule it to run at a specific time with at or cron in the background.


Have you tried nohup?

nohup command >/dev/null 2>&1 &

I promise that no matter how much she likes you, 5 seconds is too fast an interval. Really.

nohup (and in bash disown) will allow you to detach the process from the initiating terminal.


You can suspend execution by Ctrl-Z and then let it run in the background with bg ( background ).

If you want to bring it forth then fg or %.


use at or cron as john suggested, and then use wall to send her a message to her terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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