0

I have a couple tasks that I like to run periodically:

  • Push all git repositories (5 times a day)
  • Do a virus scan on files (every 90 days)
  • Download backup from server (one a day)

For all those tasks, I have a script. To orchestrate those, I wrote a script called maintenance which is part of my maintenance project. The current version of the script.

It has a JSON config file for the tasks:

"git-autopush": {
    "disk": true,
    "internet": true,
    "interval": 0.3,
    "local": false
},

I would like to replace my script with some existing task scheduler, since I would like to cut down on custom software on my system. However, I have the following requirements:

  • Do not run when running on battery.
  • Provide some visible status. That could be through kdialog even.
  • Run only one disk heavy task at a time.

The maintenance script takes care of that, and I can run it whenever I have sufficient time to let the tasks run. If not, I can just abort all the tasks and restart it later.

Plain cron would not be good, since it would not work when my computer is powered off. anacron might be better, but I assume that it would run all the tasks right after booting. Also, if I happen to need my disk for virtual machine, how would I tell the scheduler to stop?

Is there some existing program out there, or should I just continue to use my on?

1
  • I'm confused: cron is no good, because it skips tasks when system is powered off, anacron might be wrong because it might run all missed tasks at once on boot. How would you like to solve that then?
    – peterph
    Sep 27, 2013 at 18:44

1 Answer 1

3

if I happen to need my disk for virtual machine, how would I tell the scheduler to stop?

Cron and anacron are (normally) daemon services. You can stop and start them the way you stop and start any other service.

cron would not be good, since it would not work when my computer is powered off

That's a pretty tough criterion to get around. What is it you want the software to do while the computer is powered off?

anacron might be better, but I assume that it would run all the tasks right after booting.

Apparently. Here's an idea though: start and stop anacron with cron.

Run only one disk heavy task at a time

Anacron has this option:

-s
Serializes execution of jobs. Anacron does not start a new job before the previous one finished.

This just leaves you to implement these two:

  • Do not run when running on battery.
  • Provide some visible status. That could be through kdialog even.

The first could be accomplished by having cron check the battery status before it starts anacron. The second could be done a wide variety of ways; you've already suggested one yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.