how do i run a script 5mn after startup?

Solution 1:

sleep 300 is the way to go, but you need to put it in a function which you will call asynchroneous:

myscript()
{
    sleep 300

    # do what you want
}

myscript &

# continue with other things

Solution 2:

Sleeping for five minutes is a pretty unstable hack. What if something later in the boot chain takes an unusal long time to start up? And why do you want your system to take longer than necessary to boot?

The right way to do it is to make your startup script run after the stuff it depends on. How you do this differs between distros.

In Debian you specify in the script header what dependencies your script have:. Here's an example from /etc/init.d/README in Debian Wheezy:

# Required-Start:    $remote_fs $syslog

On other systems you usually name the script with a number somewhere in the filename in one of the /etc/rc?.d/ folder. On such distros, just give it a higher number than the stuff it depends on.