This guide explains how to execute a command using cron jobs every time the server starts or restarts on Ubuntu. It also covers how to mitigate the need for sudo
in the cron job and ensure the command can run without requiring password input.
- Ubuntu server
- Basic knowledge of using the command line
You can add sudo
to the command in your .profile
file if the fwconsole restart
command requires elevated privileges.
Here's how you can modify the command to include sudo
:
sudo /usr/bin/fwconsole restart
Make sure that the user running the command has appropriate permissions in the sudoers file (/etc/sudoers
) to execute fwconsole restart
with sudo
without being prompted for a password.
After adding the sudo
prefix to the command, save the changes to your .profile
file, and the fwconsole restart
command will be executed with elevated privileges the next time you log in.