0

I'm running a raspberry pi, and I would like to run a specific application (qbittorrent-nox) between 00:00 and 12:00.

Currently the service is scheduled using systemd, but I don't know what the best way is to schedule it. I am looking for a solution which does not depend on the time I start the raspberry pi.

If you need more information, please let me know.

Thanks for the help in advance!

1
  • If you want to use systemd have a look at man systemd.timer.
    – goldilocks
    May 27, 2020 at 16:53

1 Answer 1

4

I'm assuming the executable is ~/bin/qbittorrent-nox as the two examples I have seen use that (sorry do not run it myself). If not shout if you cannot change these commands.

I would use the Linux CRON system to schedule two jobs. One to start every day of the year and one to kill the job every day of the year two hours later.

Note midnight is a nightmare for scheduling as many an argument of what day of the week midnight is on has been seen. I like one minute past (00:01) or even one second past (00:00:01) as it stops any cloudy minds as to the day the job starts on :)

To generate CRONTAB entries, I use Crontab Generator dot org though others are available.

So to start the task we have an entry like this:

 * 0 * * * ~/bin/qbittorrent-nox >/dev/null 2>&1

And to kill the task you can try:

* 2 * * * pkill -9 -fu "$(whoami)" 'qbittorrent-nox' >/dev/null 2>&1

These should be set up in CRON for the same user (normally PI or ROOT) and there are many many examples of setting up this for the Pi such as:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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