Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I know how to run a program on boot, on login (System > Preferences > Startup Applications) or on opening a shell (.bashrc). I also did read "execute script after desktop loaded?". What I realized that every application added to Startup Applications extends the time until the desktop becomes usable. So I'm looking for a way to start all the "nice to haves" from a script (got that working) that runs after the regular startup is finished.

I'm not fully clear how to get there. Would I use a second script that calls the first one with & (so it runs in the background) and add a wait for (a few seconds|specific event) to the first one?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

If you're going to launch something expensive, launch it in the background with a delay. For example

after 20s find-all-the-dirty-dishes &
after 1m find ~ -name '*~' -mtime +30 -exec rm '{}' ';'

where you will have to implement after yourself but it can be something like this

#!/bin/sh
sleep "$1"
shift
exec "$@"
share|improve this answer

Just call sleep at the beginning of your "nice-to-haves" script. That shouldn't block the desktop from loading. You may also be able to speed things up on multi-core hardware by backgrounding each process.

e.g.

sleep 20s
<something that takes a long time> &
<this can now start immediately> &
...

The two commands will run in parallel, but they'll wait for 20 seconds before starting. You can use "m", "h", or "d" to specify minutes, hours, or days if a few seconds isn't what you had in mind. =)

share|improve this answer
    
Thx Jon. I guess that I would do in the startup apps: triggerNiceTohave.sh and inside triggerNicetohave.sh I do nicetohave.sh & and the sleep 20s is inside the nicetohave.sh? –  stwissel Apr 10 '12 at 8:55
    
I tried that, but the startup seems to get delayed by it - very strange. –  stwissel Apr 11 '12 at 9:29
    
You need something more complicated. Sleep is going to block startup for 20s. –  Norman Ramsey Oct 13 '12 at 22:03

Your Answer

 
discard

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.