# cron job not executing (restart Wireguard connection)

**URL:** <https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565>\
**Category:** Troubleshooting\
**Created:** [3 August 2021 15:24 UTC](https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565 "2021-08-03T15:24:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![beerenheini](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@beerenheini](https://dietpi.com/forum/u/beerenheini)\
**Post date:** [3 August 2021 15:24 UTC](https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565/1 "2021-08-03T15:24:57Z")

</div>

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

```nohighlight
crontab -e

```

(as root):

```nohighlight
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 🙂

---

<div class="post-metadata">

**Author:** ![beerenheini](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@beerenheini](https://dietpi.com/forum/u/beerenheini)\
**Post date:** [3 August 2021 15:38 UTC](https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565/2 "2021-08-03T15:38:03Z")

</div>

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

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

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

```

This does not work.

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [3 August 2021 21:47 UTC](https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565/3 "2021-08-03T21:47:26Z")

</div>

Hi,

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

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

```

---

<div class="post-metadata">

**Author:** ![beerenheini](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@beerenheini](https://dietpi.com/forum/u/beerenheini)\
**Post date:** [4 August 2021 07:50 UTC](https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565/4 "2021-08-04T07:50:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [4 August 2021 08:24 UTC](https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565/5 "2021-08-04T08:24:50Z")

</div>

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.

```nohighlight
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

---

<div class="post-metadata">

**Author:** ![beerenheini](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/b/9fc348/32.png) [@beerenheini](https://dietpi.com/forum/u/beerenheini)\
**Post date:** [4 August 2021 08:30 UTC](https://dietpi.com/forum/t/cron-job-not-executing-restart-wireguard-connection/5565/6 "2021-08-04T08:30:07Z")

</div>

Hah, your right! Thanks 🙂
