[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#923014: Add systemd unit - allow usage without cron installed



Package: popularity-contest
Version: 1.67

This is regards to the popularity-contest cron job.  I'm looking into
running systems without anacron/cron installed - instead using systemd
timers.

My suggestion would be to remove the what to do functionality from the
cron job/timing bits to another script - say popcon-runner.

The cron job could then be something like:
# skip in favour of systemd timer (from logrotate)
if [ -d /run/systemd/system ]; then
    exit 0
fi

<anything else cron specific needed to schedule when it runs>

popcon-runner

And creating a systemd timer/service for those that have systemd installed:

Timer File
/etc/systemd/system/timers.target.wants/popularity-contest.timer
[Unit]
Description=Sends popularity contest data

[Timer]
OnCalendar=daily
AccuracySec=24h  [ Can change this to be less accurate to spread
server load, etc)
Persistent=true

[Install]
WantedBy=timers.target

Service File
/usr/lib/systemd/system/popularity-contest.service
[Unit]
Description=Sends popularity contest data

[Service]
ExecStart=/path/to/popcon-runner
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7

(can easily set nice levels, IO limits)

PrivateTmp=true
PrivateDevices=true

There are a bunch of other restrictions that can be placed on it via
systemd Private directives.

Thanks!


Reply to: