Preventing duplicate cron job executions

I feel like sometimes cron jobs create more problems than they solve. It's not the fault of cron, but rather the jobs being executed. This is especially true when the jobs result in duplicate running instances like the following example. $ ps -elf | grep forever 4 S vagrant 4095 4094 0 80 0 - 1111 wait 21:59 ? 00:00:00 /bin/sh -c /var/tmp/forever.sh 0 S vagrant 4096 4095 0 80 0 - 2779 wait 21:59 ?...

 · 13 min · Benjamin Cane

8 Tips for creating better bash scripts

When I was first got started with administrating Linux and Unix servers I was working in an environment where there were tons of adhoc scripts that other admins wrote. From time to time I would find myself troubleshooting why one of those scripts suddenly stopped working. Sometimes the scripts would be well written and easy to understand, other times they were clunky and confusing. While troubleshooting the poorly written scripts was always a hassle at the time, it taught me an important lesson....

 · 11 min · Benjamin Cane

8 examples of Bash if statements to get you started

Shell scripting is a fundamental skill that every systems administrator should know. The ability to script mundane & repeatable tasks allows a sysadmin to perform these tasks quickly. These scripts can be used for anything from installing software, configuring software or quickly resolving a known issue. A fundamental core of any programming language is the if statement. In this article I am going to show several examples of using if statements and explain how they work....

 · 8 min · Benjamin Cane

5 Bash for loop examples to make command line tasks more efficient

One of the things that excited me while learning Unix/Linux was how quickly one can perform tasks via the command line. Bash is a fully functional scripting language that incorporates Variables, Loops and If/Then statements; the bash shell allows a user to use these functions while performing adhoc tasks via the command line. This is also true for the other common shells such as bourne, korn shell, and csh. Below I will show 5 example for loops that are run on the command line without being placed into a shell script....

 · 6 min · Benjamin Cane

Understanding a little more about /etc/profile and /etc/bashrc

Recently I was working on an issue where an application was not retaining the umask setting set in the root users profile or /etc/profile. After looking into the issue a bit it seemed that the application in question only applied the umask setting that was set in /etc/bashrc and would not even accept the values being the applications own start scripts. After doing a bit of researched I learned a little bit more about what exactly these files do, the differences between them and when they are executed....

 · 3 min · Benjamin Cane