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'm looking for a way to run maintenance tasks when my computer is not being used. I don't leave it on 24x7, so the ideal scenario would be for it to wait until the computer has been idle for a certain period of time (e.g. when the screen saver is running) until it runs maintenance tasks.
I've read the man pages for anacron and it seems like a piece of the puzzle - I just need a way to schedule it to run when the computer is idle. After reading the man page on cron, I didn't see any option in there that would help.
I've searched Google linux and Google groups without much luck:
schedule tasks cpu OR computer idle
cron task idle
etc.
Simply schedule the task to occur whenever at priority 19. It will use idle CPU cycles, and not interfere to any significant degree with active processes. If you don't leave you computer on all the time, you can use the '@reboot' special cron time to run the process some time after the machine is started. For example:
In Windows, I found that option to be less than optimal. Even though these maintenance tasks were run at the lowest priority, if they were disk I/O intensive processes, they would tend to block higher priority processes that were also competing for disk I/O time. I'm assuming this is because it's not as easy to schedule disk time as it is CPU time.
I'm not sure if it would also be a problem with Linux or not.
The above will be started after the system is booted and
1- Delay 15 minutes
2- Check every 5 minutes to see if the screen saver has activated
3- Run '/usr/local/bin/myprogram' when the screensaver has activated
Of course, if you return to the system after the screensaver has started, you are back to the same issue.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.