0

I have a bash script I'd like to run at boot (both reboot and from cold boot) using the latest Ubuntu server version.

I've confirmed the script works when running it directly.

I ran

sudo crontab -e

and added the following to the file

@reboot ./wol.sh

I've confirmed that the script runs successfully when I run it myself using

sudo ./wol.sh

but it doesn't run when I restart Ubuntu with

sudo shutdown -r now

If it's relevant here's the bash file

#!/bin/bash

etherwake MAC_ADDRESS -i enp1s0

I also set the permissions to the file as chmod 700

What am I missing? Thanks in advance.

Woogz
  • 1
  • Hello. There is no such version of Ubuntu as latest. Also in the future this will not be the latest. So an actual version number is required. – David Apr 14 '22 at 14:29
  • It's important that you use the full /path/to/script when running from cron, and not ./script. This is also stated in the duplicate Q&A above. – Artur Meinild Apr 14 '22 at 14:39
  • Thanks guys. I installed realpath to figure out what the actual path of my file was then added the full path to the crontab file and still couldn't get it to work but then doing the same to my systemd service file worked perfectly. – Woogz Apr 14 '22 at 14:51

0 Answers0