I was Looking for some daily commands to be executed on my server ubuntu 20.04. Please help me
Commands to be daily executed on night 11:25pm
sudo service apache2 restart sudo apt update sudo apt upgrade -y sudo apt autoremove -y sudo reboot
Please help me. Thanks in advance
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
You correctly mentioned crontab. You can configure this as a script to run every day at 11:25pm.
Let’s first start with creatng the script. SSH to your droplet and start executing the following commands
The above will create the file for you. Now it’s time to edit it.
Inside of it, you can type in the following
Save the file and exit. Now time to make sure your script is executable
Now the last bit, add it to your crontab. To do that, type in
WHen the file opens at the bottom of it, add the following line
Save the file and exit from it. To make sure you’ve added the cron, type in
You should see the command you added at the bottom.
A word of caution: there are times when going through the update/upgrade process requires user input beyond the -y flag. There are times an upgrade will change a config file that would wipe out any customizations you have previously set up, or change the location of a file, etc. This has the potential to make the cron script hang or fail every day until you check on it again.
My personal recommendation is to run the update/upgrade as a manual process.
For a suggestion on a script to run daily might be to have server logs emailed to you.
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now