Reputation: 484
Tried two methods and neither seem to be working:
crontab -e
:
@reboot sleep 60;/home/linuxbox/script.sh
and created a service in /etc/systemd/system/script.service
:
[Unit]
Description=a generic service to run on reboot
[Install]
WantedBy=multi-user.target
[Service]
ExecStart=/bin/bash /home/linuxbox/script.sh
Type=simple
User=linuxbox
Group=linuxbox
WorkingDirectory=/home/linuxbox
I follow that up with systemctl daemon-reload
.
Not sure what is going wrong at this point -- any help is appreciated.
Upvotes: 0
Views: 1797
Reputation: 11
Have you enabled cron?
You can enable and start it with
sudo systemctl enable cron.service
Upvotes: 1
Reputation: 31274
Once you've created your script.service
unit, you must of course enable it:
systemctl enable script.service
(This might seem obvious, but in qour question you only mention that you run systemctl daemon-reload
which is not enough)
Upvotes: 0
Reputation: 361
The ExecStart
command shouldn't be
/bin/bash /home/linuxbox/script.sh
but should be
/bin/bash -c "/home/linuxbox/script.sh"
.
Upvotes: 0