Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've never used the `at` tool, so it may be the right tool for the job, but I don't know.
But what about running the script (forking it off) directly from your rc.local init script (or your distro's equivalent init script) and inside your script, have a sleep loop of 300 seconds, after which it continues on to doing the actual good stuff?
@ bathory: I never checked out the at command, ill have a look at it. ty! EDIT: Had a quick look at the "at" command, isnt that only for starting stuff at a specific time? inned to start it directly after boot up, whenever that might be
@ GrapefruiTgirl: i run ubuntu 9.04, i understand what your saying here. Still im a abit scared of messing up there since i dont really know how to use it, could you elaborate on it?
I don't use ubuntu, so there's probably a more appropriate way to do it on that OS, though the principle is the same.
Either:
A) inside one of the rc.d folders (or inside any that are relevant to your desired runlevels where you want your script executed)
OR
B) within an existing script as mentioned,
You would put a line like:
Code:
/path/to/your/script &
The & symbol makes the script fork off into the background, while the parent script continues along its merry way.
And now, the first line of your special script, would read:
Code:
sleep 300
which would induce a 5 minute delay before the rest of the script was executed.
Again, there's a "prefect" way to do this on Ubuntu, which another Ubuntu user will have to explain to you, about how to induce scripts to execute the correct way at bootup in various runlevels, using the init.d folders.
@ bathory: I never checked out the at command, ill have a look at it. ty! EDIT: Had a quick look at the "at" command, isnt that only for starting stuff at a specific time? inned to start it directly after boot up, whenever that might be
No, you can also tell at to start after a specified amount of time. In you case you can put the following in rc.local
Code:
at -f /path/to/script now + 5 min
and it will run your script 5 minutes after rc.local is ran. You can verify it with atq.
I just tried to put:
at -f /path/randomprogram now + 2 minutes
Just to see that everything was kicking and a process was staring. And it actually wasn't, i could see it with atq but it never start. I tried with a script that created a new file as well and it never started either.
Is there some special way to place the line in rc.local or is it just to ram it in there in there at the last line?
Just to see that everything was kicking and a process was staring. And it actually wasn't, i could see it with atq but it never start. I tried with a script that created a new file as well and it never started either.
You have to make sure that the atd daemon is running.
Quote:
Is there some special way to place the line in rc.local or is it just to ram it in there in there at the last line?
You can put the line where you want. Just to be sure, use the full path to the at command:
Code:
/usr/bin/at -f /path/randomprogram now + 2 minutes
Why would you need to have su or sudo in this case? Isn't the /path/to/your/script being called from rc.local which is run during the init process by the superuser, who would have full priviledges? So wouldn't the superuser execute /path/to/your/script at the appropriate time?
Why would you need to have su or sudo in this case? Isn't the /path/to/your/script being called from rc.local which is run during the init process by the superuser, who would have full priviledges? So wouldn't the superuser execute /path/to/your/script at the appropriate time?
Yes it would and presumably that is not what is wanted.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.