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 ?
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.
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.
In the world of Cloud Servers and Virtual Machines scripting and automation are top priority for any sysadmin. Recently while I was creating a script that logged into another server via SSH to run arbitrary commands, I ran into a brick wall.
$ ssh 192.168.0.169 The authenticity of host '192.168.0.169 (192.168.0.169)' can't be established. ECDSA key fingerprint is 74:39:3b:09:43:57:ea:fb:12:18:45:0e:c6:55:bf:58. Are you sure you want to continue connecting (yes/no)? To anyone who has used SSH long enough the above message should look familiar.
For me when it comes to useful commands xargs ranks along side commands like find, top and df; xargs is a great time saver and incredibly useful. Today I will show a few examples of usage and some of the lesser known features.
Basic Usage The xargs command is used to take the output of one command and provide it as arguments to another.
# ls [0-9]-test.xml | xargs chmod -v 644 mode of `1-test.
One of the primary tricks in my sysadmin bag-o-tricks is Input/Output Redirection; I have found that while many people use Shell I/O Redirection throughout their day not everyone fully understands why and how it works.
The Input and Output In the Unix environment there is always 3 streams open stdin, stdout, & stderr; these special streams are used for interacting with the user input and program output within the Unix/Linux shell environment.
I figured I would start a new category for command line quickies. Here is one that I have found very useful.
# find ./ -type f -daystart -ctime -1 This is a very nice way of finding files created today. Now this command differs from the command below.
# find ./ -type f -ctime -1 The -daystart flag will tell find to use the beginning of the day when searching for files created today.