msgbartop
Tips, notes, HOWTOs
msgbarbottom

18 Dec 08 Remembering The Order Of Time/Date Fields For Cron

If you have a hard time remembering the order of the times/dates fields of a crontab record this header might help you.  I use this on all of my crontabs.  Each value, if tab seperated should line up under the correct heading.

#
#min    hr      day     mon     dayofwk         cmd
#
#-------------------------------------------------------------------------------

Tags: , , ,

18 Dec 08 Spawning Sub-Shells

Creating sub-shells in bash is simple: just put the commands to be run in the sub-shell inside parentheses. This causes bash to start the commands as a separate process. This group of commands essentially acts like a separate script file, their input/output can be collectively redirected and/or they can be executed in the background by following the closing parenthesis with an ampersand.

#!/bin/bash

server_cmd=server
pid_file=$(basename $server_cmd .sh).pid
log_file=$(basename $server_cmd .sh).log

(
    echo "Starting server"
    echo "Doing some init work"
    $server_cmd   # server becomes a daemon

    while true
    do
        if [[ -f $pid_file ]]; then
            sleep 15
        else
            break
        fi
    done
    mail -s "Server exitted" joe@example.com <<<CRAP

) 2>&1 >> $log_file &

echo "Server started"

quote and example via LinuxJournal

Tags: , , , ,

18 Dec 08 Remembering The Shell’s Special Variables

I can never seem to remember what all of these default parameter variables are.  I found this small shell script that prints them out when I forget.

#!/bin/sh -vx
#######################################################
# example_1.1 (c) R.H.Reepe 1996 March 28 Version 1.0 #
#######################################################
echo "Script name is            [$0]"
echo "First Parameter is                [$1]"
echo "Second Parameter is               [$2]"
echo "This Process ID is                [$$]"
echo "This Parameter Count is   [$#]"
echo "All Parameters            [$@]"
echo "The FLAGS are                     [$-]"

It produces output like this:

#!/bin/sh -vx
#######################################################
# example_1.1 (c) R.H.Reepe 1996 March 28 Version 1.0 #
#######################################################
echo "Script name is            [$0]"
+ echo 'Script name is            [/home/me/bin/shellhelp]'
Script name is            [/home/me/bin/shellhelp]
echo "First Parameter is                [$1]"
+ echo 'First Parameter is                []'
First Parameter is                []
echo "Second Parameter is               [$2]"
+ echo 'Second Parameter is               []'
Second Parameter is               []
echo "This Process ID is                [$$]"
+ echo 'This Process ID is                [15190]'
This Process ID is                [15190]
echo "This Parameter Count is   [$#]"
+ echo 'This Parameter Count is   [0]'
This Parameter Count is   [0]
echo "All Parameters            [$@]"
+ echo 'All Parameters            []'
All Parameters            []
echo "The FLAGS are                     [$-]"
+ echo 'The FLAGS are                     [hvxB]'
The FLAGS are                     [hvxB]

via Richard’s Unix Shell Scripting Universe

Tags: , , ,

17 Dec 08 Watching And Saving Command Output With ‘tee’

You can watch command output on stdout as well as saving that output to a file for later analysis with the tee command.

me@home:~$ date |tee teefile.txt
Wed Dec 17 10:50:21 CST 2008
me@home:~$ cat teefile.txt
Wed Dec 17 10:50:21 CST 2008
me@home:~$

Tags: , ,

16 Dec 08 Extend LVM2 Logical Volume

I found myself recently having to add some space to one of my LVM partitions.  It’s fairly simple.  First extend the partition size with lvextend:

lvextend -L+1G /dev/myvg/homevol

Then, because I use ReiserFS I do:

resize_reiserfs -f /dev/myvg/homevol

If you use a different underlying filesystem refer to this page from the LVM HOWTO.

Tags: , , ,

16 Dec 08 WP 2.7 Upgrade

I just updated to WordPress 2.7.  Comment to this post if you notice any issues.

09 Dec 08 What Are My ‘sudo’ Permissions?

Quick command to see what you can run with elevated permissions via sudo:

sudo -l

Tags:

08 Dec 08 Global Search And Replace In Vi

To perform a global search and replace in vi do:

:%s/search_string/replacement_string/g

If you want to confirm each replacement add a “c” after the “g” at the end of the string.

Tags: , ,

07 Dec 08 Use Refractor (Prism) Firefox Addon In Ubuntu

You can get Refractor (Prism addon) to work in Ubuntu (and probably other unices) with one added step to the install process.

After installation you need to right click the icon and choose Properties.

Original Properties

Original Properties

In the Command box change “firefox”, for me it was “/usr/lib/firefox-3.0.4/firefox”, to xulrunner.

New Properties

New Properties

Tags: , , , , , ,

06 Dec 08 Increase Loadaverage

Increase the load average on a machine for testing.

while true; do w & w & w & w; done

Tags: ,

SEO Powered by Platinum SEO from Techblissonline