cron job not executing (restart Wireguard connection)

Hi Forum! How are you? Long time no see…

I’m having trouble running the most simple cron job.

I’ve added the following by entering

crontab -e

(as root):

20 12 * * * /bin/date > /tmp/date.log

But nothing’s happening. I also tried putting a new file „date“ into /etc/cron.d/ but nothing’s happening as well.

The exact same thing on another server running Ubuntu (20.04.2 LTS) runs the job with no issues.

I’m lost, as the other jobs in cron.d/ (php, pihole, rsnapshot) run fine…

Thanks for any suggestions :slight_smile:

Okay… restarting the cron.service does the job for aforementioned command.

What I really want to do is resetting my Wireguard connection by doing:

36 17 * * * '/usr/bin/wg-quick down' && '/usr/bin/wg-quick up'

This does not work.


I would recommend to restart the service instead of trying to sop/start Wireguard

/bin/systemctl restart wg-quick@wg0.service

Hi Joulinar,

thanks for your suggestion! This seems to have worked :slight_smile:

Could you enlighten me, why that’s the case compared to wg-quick up?


I guess you missed to specify the interface name for Wireguard to start/stop. At least the service is doing nothing else as you did, just with an interface name specified.

ExecStart=/usr/bin/wg-quick up %i
ExecStop=/usr/bin/wg-quick down %i
ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)'

variable %i is specified within the service name wg-quick@wg0 right after @. Means, the interface name is wg0

Hah, your right! Thanks :slight_smile: