mintCast 319.5 – Cron (mp3)
This week, in our Innards section, we chat about the terminal and cron. And finally, community feedback!
- Using terminal in Debian based systems.
- sudo apt update – updates the repositories
- sudo apt upgrade – updates packages
- sudo apt dist-upgrade only updates packages used in your system and removes what it is replacing
- ls – lists file and directories in the current directory
- ls -a list all files and folders including those hidden with a period at the beginning of name
- lshw – list hardware
- lscpu – lists cpu info
- lsusb – lists usb hubs/connected devices
- top (Htop if installed) – list top most resource intensive services while running typing M will sort by memory use typing C will sort by CPU usage
- ip link show – show all ethernet and wifi devices
- Leo’s Edit: ip -c a will give general network info colorized!
- cd – change the current directory
- cd .. – takes you back to the previous directory
- cd /full/path
- cd / takes you to the root directory
- man (name of package) opens up a manual of the application
- (command) > file.txt – puts a text file of the command output into the current working directory. (where file is the name you give the text file output.
- nano file.txt – opens the file in the terminal
- Cron: an extremely powerful scheduling tool made in 1975.
- Used for running bash commands at designated times
- Generally used for scheduling system maintenance but its general purpose nature makes it perfect for downloading files from the internet moving files to new locations.
- Including commands to run scripts
- /usr/bin/env bash /full/path/script.sh
- The best thing is being able to set up timing
- Crontab -l crontab -e
- Also wanted to mention that I set up a working instance of auto-update in cron for my server
- Generally not a fan of autoupdate my preference is to do it manually
- But the setup is kinda easy
- nano file.sh
- Cron: an extremely powerful scheduling tool made in 1975.
#!/bin/bash apt-get update apt-get upgrade -y apt-get autoclean
- Chmod 755 on the file
- 0 5 * * 1 /usr/bin/env bash /home/user/update.sh
- Leo’s Edit: Add it to root’s crontab with sudo crontab -e
- Here is how the timings work:
- Min: the minute of the hour (0-59).
- Hour: the hour of the day (0-23).
- DoM: the day of the month (1-31).
- Mon: the month of the year (1-12 or Jan-Dec).
- DoW: the day of the week (0-6 or Sun-Sat).
- Command: anything you can normally run on a command line.
- @yearly (or @annually)
- @daily (or @midnight)
- @reboot (most useful)
- Cron Expression Generator & Explainer – Quartz
- What? That is too difficult you say? Well there is another way:
- These folder locations simply create your bash script make it executable and dump them into the corresponding folder
- Last time I brought up cron i mentioned one of the issues is that you could have overlapping commands if you did not give enough time between your commands. I was speaking with Toyam and he gave me a great idea. Use a simple lockfile and an if statement
#!/bin/bash FILE=/home/user/my_file if [ -f "$FILE" ] then stop else touch $FILE apt-get update apt-get upgrade -y apt-get autoclean rm $FILE fi
- Cron is an extremely powerful yet low level tool that can help you automate everything
- Londoner from Telegram: recommends `ll` instead of `ls -l`
- Leo – Practical cron
- I talked about a script that updates my Dynamic DNS information in the first half of the show. Here’s exactly what I did to make it work.
- I start with deciding when I need this thing to run. In the case of my Dynamic DNS, I decided every 6 hours would be good enough. Afraid.org had an example that was something like every 5 minutes. I felt that was too much for a free service, so I scaled it back.
- If I ever do cron stuff that’s more complex than once a day, I use a calculator to check myself, or to just do the heavy lifting for me.
- This is the line I have in my Pi-Hole VM that takes care of Dynamic DNS.
- 2 0,6,12,18 * * * /home/leo/afraid.org-ddns-update
- This is just a text file that has two separate commands inside of it.
- date >> ~/ddns-update.log
- curl http://freedns.afraid.org/dynamic/update.php?XXXXXXXXXXXXXX >> ~/ddns-update.log
- I didn’t even add the typical #!/bin/bash line to it. Literally only those two lines.
- Each line does two things.
- The date line takes the current date and time and adds it to a file called ddns-update.log
- The curl line accesses the afraid.org site, and adds the response to the ddns-update.log.
- Moss – Grub Customizer
They put me at the end to wake up all the n00bs and non-techies.
Grub Customizer is an easy-to-use way to organize your boot sequence, and can be used to clean things up a bit. It has its detractors, but they are mostly people who would rather write their own Grubs, and that does not include me. Where do you find it? How do you install it?
- Debian 10, Endeavour — it’s in your repo
- Ubuntu, LinuxMint, Feren, other Ubuntu-based distros
- sudo add-apt-repository ppa:danielrichter2007/grub-customizer
- sudo apt update
- sudo apt install grub-customizer
- Other non-Ubuntu distros – no clue, compile the binary?
- After installing just look for Grub Customizer in your menus and double-click it, or just run “sudo grub-customizer” in Terminal
- You can move distros up and down in the boot order, delete “advanced” boots, etc. as desired.
- When you boot after that, you will have the menu in the order you wanted, and it will autoboot to the top listed distro.
- There are ways to pretty up the boot menu appearance, but in my experience I just make it uglier. You’re on your own here.
- Henrik Hemrin
Sync and backup, two related topics which also are easy to confuse yourself about… are interesting, and thanks for sharing your knowledge today! I’m not there yet to have everything automized, nor which will be my “final” solution.
Talking about RAID, trying to remember many years back when I had a RAID mirroring setup, and as I recall data became corrupted on the “main” drive, which meant also the mirror soon was corrupted. That can be correct memory, right? So mirroring is a backup for broken discs, but will not be a lifeline for all data troubles.
A reflection about sync to an own eg NextCloud cloud server at home, is that a backup is still relevant to have, at another location. Right? One option is a eg to have USB discs, swap them and keep one at the time at another geographic place. Another option is to have a cloud storage for backup. But I believe, if I have a cloud storage, that company should have a backup system for the service, and then a local sync server is not really needed… but of course an advantage to have a sync and access without internet.
Another general thought about sync, similar to my RAID discussion above, is like in Leo’s case with three Mint machines; if you by mistake delete your home directory on one machine, the sync will delete it on the server, as well as on the other two machines? And on any automatic backup. Which means the backup, sync, or both, must have several versions stored?
Hope you can follow my thoughts – and maybe give a comment any answer or tell me I mess up and think wrongly.
- Joe Boylan <email@example.com>
I follow your thoughts and you are correct. it is a good reason to have a bit of time setup between your rsync backups. The resilio sync I think I said I don’t recommend as that type of backup but is good for restoring when one system has a catastrophic sudden failure.
- George from Tulsa
Guys, please, this content is not appropriate for a podcast, and if it is, that podcast is not the Mintcast. “Magic” words, e.g., nodes re BT Sync, only make sense in context the normal Mintcast listener doesn’t have. A show that’s so deeply geeky conflicting cron jobs have to be mentioned as dangers is just too deep for audio. To use Heinlein’s term, no one listening who doesn’t already know the subject will grok that content as it streams by in audio, in my case, while driving, for deity’s sake.
If you want to get that deep, you need written tutorials starting at the very beginning. You’ll have to teach about permissions, cron, rsync options, and more.
Far more appropriate for Mintcast would be in depth discussion how to use Mint’s built in tools, TimeShift, Mint backup, and what they will and won’t do, plus exercises in restoration.
Then cover GUI tools like LuckyBackup and Déjà Dup. Maybe Clonezilla –
- Joe Boylan <firstname.lastname@example.org>
to George, MintCast
We will be discussing conflicting cron jobs on this weekends show. Also how to prevent them. We have had less in-depth shows lately and it has been mentioned by several listeners that they would like more deep dives on topics. We will also move into more gui related topics at some point as well we are trying to line up more interviews with people.
- <Moss> MintCast has been doing deep dives from the beginning, Rob and Isaac were famous for them. I do like the idea of deep dives into LM tools.
- George from TulsA
Thanks for the response. In depth is very difficult in audio –
CHECK THIS OUT:
- Leo – If you’re in Telegram, I show how I keep track of my keys. RJ45 Loopbacks!
- Tony H – Full Circle Magazine – needs new writers – this community magazine which has been going for 12 years needs new writers to come forward and contribute to the magazine. Read this months editorial.
- Moss – You Can Now Use OneDrive in Linux Natively Thanks to Insync
- Tony – late reminder for OggCamp 19/20 October
- Leo – late addition: https://www.skysilk.com/cloud/pricing/#classId=Standard§ion=1
Next show is Sunday October 20th, 2PM CDT / 7PM UTC
- Joe – www.Tllts.org www.linuxlugcast.com MeWe email@example.com
- Bo – undercastnetwork.com
- Moss – Triad Bardic College, Peaceful Hippo, MeWe, music on Bandcamp and all over YouTube (search for Moss Bliss, ignore the young black South African gospel singer), firstname.lastname@example.org, email@example.com
- Tony Hughes – HPR – http://hackerpublicradio.org/correspondents.php?hostid=338
- Tony Watts – firstname.lastname@example.org, Echoes of Savages (band)
- Josh – email@example.com, firstname.lastname@example.org, edublocks.org and @all_about_code on Twitter
- Leo – leochavez.org and @leochavez on Twitter, and Full Circle Weekly News
Before we leave, we want to make sure to acknowledge some of the people who make mintCast possible …
- Josh Lowe for all his work on the website and the livestream (We’ve had over 60 listeners today on the backup mixer platform and brought on some new listeners who’ve never heard of the podcast)
- Bytemark Hosting for hosting mintcast.org and our Mumble server
- Archive.org for hosting our audio files
- The Linux Mint development team for the fine distro we love to talk about <Thanks, Clem!>