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 saw this come up in this thread, but I thought I should start a separate thread for this question. Please let me know if I should have kept this in the original thread.
I was wondering what the difference is in using at or sleep. The case I'm thinking of comes from the thread linked above:
case 1:
somewhere in /etc/rc.d/rc.local
at -f /path/to/script now + 5 min
case 2:
somewhere in /etc/rc.d/rc.local
/path/to/your/script &
at the top of /path/to/your/script
sleep 300
Specifically, I was wondering in terms of process context switch - which I know little about. I assume there is an efficient context switch in case 1 such that /path/to/script won't be eating up cpu cycles the first 5 mintues of its calling. Is the behavior the same for case 2? I assume the sleep command does not eat up cpu cycles according to this thread, but I wasn't sure.
I would also appreciate any other difference that you see between the two cases. Thanks.
Sorry to interrupt in between, but what would be the better idea of scheduling a job...'at' or 'sleep' , especially when the cpu resources are the major concern for the execution of the job?
Sorry to interrupt in between, but what would be the better idea of scheduling a job...'at' or 'sleep' , especially when the cpu resources are the major concern for the execution of the job?
Thank you for the reply....
I have a script that needs to be run in 1 hr of interval for three times in the night time. Script adds 100 records to Oracle table after every 1 hr. I was thinking to set 'at' like that it executes after every 1 hr on its own, but I lost it to stop and it keeps on executing after every 1 hr throughout the night untill unless we manually stops that.
Wouldn't the & allow the rest of rc.local to get executed without waiting for /path/to/your/script to finish executing?
Also, how does the sleep command work exactly. This thread seems to explain that the sleep command doesn't eat up cpu cycles, but that a context switch occurs with the process, and the operating system will awaken the process after 300 seconds. So during the 300 seconds, no cpu cycle is used for /path/to/your/script. Is my understanding of this correct?
case 2: note: you have TWO files here
somewhere in /etc/rc.d/rc.local
/path/to/your/script &
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.