Linux – How to automate commands that I run every day on Linux


Every morning, I SSH into a particular server. I check disk space, size of a few directories, and the contents of some specific directories.

All of this involves a lot of typing and recall (of directory locations) when I am not at my most awake.

Is there a smarter way of doing this… some kind of script that takes out some of the manual typing that I do every morning?

Best Answer

You could probably do the majority of that from a bash script, yes. And get it to run every day by putting it in cron.daily, or your distro's equivalent.

Conceptually, you can call the same commands from the script as you do manually, but you'll probably want to redirect the output to append a temporary file, and then sendmail the contents of that file to yourself once done so you can just read the summary.