Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 a bash script (let's call it which looks like this

while true; do
  if [ $someFile -eq = "1" ]
    # make laptop LED blink here

So when some file has some value (in my case, this file is changed when messages arrives), the script make a LED blink. As you can guess, this script never stops.

I usually call it when I need to know wether there is new mail and I can't open the laptop and check the screen.

Today I said to myself: let's put this in .bash_profile so the script gets fired up at login.

But when I try to login, alas the screen freezes.

How can I tell bash: execute this, but in a non blocking way?

Or: is there another solution to fire this at startup without freezing the machine?

share|improve this question

Nice thought. But, you have stalled the login sequence in your infinite loop :-)
So, try to launch your script with a command like,

nohup ~/ &

That way, it will be sent into background and let your login continue.

Better still, read up about cron and sleep ...

share|improve this answer
mhhh, I can login with nohup ~/ &, but it seems the script is not working... – Sefertto Apr 10 '13 at 16:25
Why nohup? Sending it to the background should be enough shouldn't it? – terdon Apr 10 '13 at 16:37
@terdon, just a habit :) you are right, send it to background is the idea. – nik Apr 10 '13 at 17:36

The best way would probably be to add this to cron. Create a crontab with the following line:

@reboot ~/ &

There may also be complications from the way you are making the led blink. You might get better answers if you include the entire script so we can see what is going on.

share|improve this answer

Rather than running this via cron with an explicit loop, read up on inotify, "a Linux kernel subsystem that acts to extend filesystems to notice changes to the filesystem, and report those changes to applications".

The inotify-tools tools documentation show how to install and give usage examples.

share|improve this answer

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.