How do I run a script as sudo at boot time on Ubuntu 18.04 Server? [duplicate]
Matthew Martinez
How do I run a script as sudo at boot time?
I need to run ethtool --offload <net> rx off to disable the annoying jme udp checksum error message.
2 Answers
You can create a systemd service.
Create a file /etc/systemd/system/ethtool.service:
[Unit]
Description=ethtool script
[Service]
ExecStart=/path/to/yourscript.sh
[Install]
WantedBy=multi-user.targetAnd script /path/to/yourscript.sh (don't forget to chmod +x it)
#!/bin/bash
ethtool --offload <net> rx offEnable your service
systemctl enable ethtoolIt will run on boot as root.
2Put your commands in /etc/rc.local or create that file if it does not exist:
touch /etc/rc.local chmod +x /etc/rc.localAll these actions have to be done as root.
2