cron job not executing (restart Wireguard connection) Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
Post Reply
beerenheini
Posts: 20
Joined: Tue Mar 15, 2016 2:56 pm

cron job not executing (restart Wireguard connection)

Post by beerenheini »

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

Code: Select all

crontab -e
(as root):

Code: Select all

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 :)
Last edited by beerenheini on Wed Aug 04, 2021 10:31 am, edited 1 time in total.
beerenheini
Posts: 20
Joined: Tue Mar 15, 2016 2:56 pm

Re: cron job not executing

Post by beerenheini »

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

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

Code: Select all

36 17 * * * '/usr/bin/wg-quick down' && '/usr/bin/wg-quick up'
This does not work.
User avatar
Joulinar
Posts: 5999
Joined: Sat Nov 16, 2019 12:49 am

Re: cron job not executing

Post by Joulinar »

Hi,

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

Code: Select all

/bin/systemctl restart wg-quick@wg0.service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
beerenheini
Posts: 20
Joined: Tue Mar 15, 2016 2:56 pm

Re: cron job not executing

Post by beerenheini »

Hi @Joulinar,

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

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

Thanks!
User avatar
Joulinar
Posts: 5999
Joined: Sat Nov 16, 2019 12:49 am

Re: cron job not executing

Post by Joulinar »

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.

Code: Select all

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
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
beerenheini
Posts: 20
Joined: Tue Mar 15, 2016 2:56 pm

Re: cron job not executing

Post by beerenheini »

Hah, your right! Thanks :)
Post Reply