I have a daily habit of logging into my headless server via ssh and running "apt update" and "apt list --upgradable" to see what needs to be updated. I don't like the idea that my server will auto-update and possibly break without me knowing what caused it. I've also decided to automate more of my daily tasks, and this was the next one (my server already checks for and updates my media server automatically).
Now, I should see this every morning:
Cool!
In case anyone wants to see it, here's the notify command:
ssh office 'DISPLAY=:0 notify-send "Server has these packages to update:" "`apt list --upgradable`"'
- I installed openssh-server to my desktop, locked it down to only accepting incoming traffic from my server, changed the port from the default 22 as is my habit.
- Then, to make scripting easier, I created secure keys on the server and transmitted it to my desktop, and configured ssh client on the server to use the correct port and hostname for messages. Now I don't need a user password or hostname to send messages to my desktop.
- Next, I wrote a bash script that runs the two apt commands and put in the the root folder. The script sends the output of "apt list --upgradable" to my desktop using notify-send.
- Finally, I added a cron job to root crontab to run the script everyday at 8:30am
Now, I should see this every morning:
Cool!
In case anyone wants to see it, here's the notify command:
ssh office 'DISPLAY=:0 notify-send "Server has these packages to update:" "`apt list --upgradable`"'
Comment