Posterous theme by Cory Watilo

RESTARTING PROCESSES

RESTARTING PROCESSES

There are times when you are
testing a process and have to
restart it again and again.

Instead of doing a ps -ef to
know the pid and kill it manually
every time, you can automate the
process by using the following in
a script.

kill `ps -ef | grep \`whoami\` | grep myProcess | grep -v grep
| awk '{print $2}'`

The ps command on your flavor may
use "ax" instead of "ef".  Where
myProcess is the process that needs
to be restarted.  The awk commands
gets the 2nd field of the line, which
in this case is the PID.

DAILY BACKUP CHECK

DAILY BACKUP CHECK

System administrators have to
check by various means whether
the daily backup is sucessfully
completed.

One way is to
maintain a short log file which
will log 4 or 5 lines everytime
the backup is completed.

The latest backup results will be
automatically checked by System
administrator on login, if he adds
these lines at the end of his
.profile file.

tail -5 /PATH/SHORT_LOG_FILE.log

GZIP ZNEW AND COMPRESS

GZIP ZNEW AND COMPRESS

In HP Unix "compress" command will compress
around 50 to 60%.  "gzip" will compress the
file upto 80%. There is a command available
in HP's unix to convert a compress file to
a zip file. "znew" will automatically
convert compressed files(*.Z) to gunzip
files(*.gz).

Example:
$ znew test.Z

THE BAD AND THE GOOD

THE BAD AND THE GOOD

I cringe anytime I see someone code inefficiently.  Here are
three of the most common mistakes, followed by a better way to
do the same thing.

Bad:    cat somefile | grep something
Better: grep something somefile
Why:    You're running one program (grep) instead of two (cat
and grep).

Bad:    ps -ef | grep something | grep -v grep
Better: ps -ef | grep [s]omething
Why:    You’re running two commands (grep) instead of three (ps
and two greps).

Bad:    cat /dev/null > somefile
Better: > somefile
Why:    You're running a command (cat) with I/O redirection,
instead of just redirection.

Although the bad way will have the same result, the good way is
far faster.  This may seem trivial, but the benefits will really
show when dealing with large files or loops.

RUN DAILY WITH AT

RUN DAILY WITH AT


UNIX provides a command called "at"
which can be used to run jobs according
to the specfied time.

To run a particular job in every hour,
every day use the following set of
commands in a file called "at.sh" which
will be executed recursively everyday.

########### CUT HERE ##################

#! /usr/bin/sh

# dt is a variable used to store
# current date

dt=`date | cut -c5-10`

# tm is a variable used to store
# current time

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

# "at" is the command ad -f is the
# option used to execute a specified
# file. "file Name" should be an
# executable file.

 at -f  ./"file Name" $tm $dt
 tm=`expr $tm + 1`
done

# With out manual intervention, automatic
# change over to the next day's job
# scheduling

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################

Unix Tips - Home
Posterous theme by Cory Watilo

RESTARTING PROCESSES

RESTARTING PROCESSES

There are times when you are
testing a process and have to
restart it again and again.

Instead of doing a ps -ef to
know the pid and kill it manually
every time, you can automate the
process by using the following in
a script.

kill `ps -ef | grep \`whoami\` | grep myProcess | grep -v grep
| awk '{print $2}'`

The ps command on your flavor may
use "ax" instead of "ef".  Where
myProcess is the process that needs
to be restarted.  The awk commands
gets the 2nd field of the line, which
in this case is the PID.

DAILY BACKUP CHECK

DAILY BACKUP CHECK

System administrators have to
check by various means whether
the daily backup is sucessfully
completed.

One way is to
maintain a short log file which
will log 4 or 5 lines everytime
the backup is completed.

The latest backup results will be
automatically checked by System
administrator on login, if he adds
these lines at the end of his
.profile file.

tail -5 /PATH/SHORT_LOG_FILE.log

GZIP ZNEW AND COMPRESS

GZIP ZNEW AND COMPRESS

In HP Unix "compress" command will compress
around 50 to 60%.  "gzip" will compress the
file upto 80%. There is a command available
in HP's unix to convert a compress file to
a zip file. "znew" will automatically
convert compressed files(*.Z) to gunzip
files(*.gz).

Example:
$ znew test.Z

THE BAD AND THE GOOD

THE BAD AND THE GOOD

I cringe anytime I see someone code inefficiently.  Here are
three of the most common mistakes, followed by a better way to
do the same thing.

Bad:    cat somefile | grep something
Better: grep something somefile
Why:    You're running one program (grep) instead of two (cat
and grep).

Bad:    ps -ef | grep something | grep -v grep
Better: ps -ef | grep [s]omething
Why:    You’re running two commands (grep) instead of three (ps
and two greps).

Bad:    cat /dev/null > somefile
Better: > somefile
Why:    You're running a command (cat) with I/O redirection,
instead of just redirection.

Although the bad way will have the same result, the good way is
far faster.  This may seem trivial, but the benefits will really
show when dealing with large files or loops.

RUN DAILY WITH AT

RUN DAILY WITH AT


UNIX provides a command called "at"
which can be used to run jobs according
to the specfied time.

To run a particular job in every hour,
every day use the following set of
commands in a file called "at.sh" which
will be executed recursively everyday.

########### CUT HERE ##################

#! /usr/bin/sh

# dt is a variable used to store
# current date

dt=`date | cut -c5-10`

# tm is a variable used to store
# current time

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

# "at" is the command ad -f is the
# option used to execute a specified
# file. "file Name" should be an
# executable file.

 at -f  ./"file Name" $tm $dt
 tm=`expr $tm + 1`
done

# With out manual intervention, automatic
# change over to the next day's job
# scheduling

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################

whoami Unix Tips - Home
Posterous theme by Cory Watilo

RESTARTING PROCESSES

RESTARTING PROCESSES

There are times when you are
testing a process and have to
restart it again and again.

Instead of doing a ps -ef to
know the pid and kill it manually
every time, you can automate the
process by using the following in
a script.

kill `ps -ef | grep \`whoami\` | grep myProcess | grep -v grep
| awk '{print $2}'`

The ps command on your flavor may
use "ax" instead of "ef".  Where
myProcess is the process that needs
to be restarted.  The awk commands
gets the 2nd field of the line, which
in this case is the PID.

DAILY BACKUP CHECK

DAILY BACKUP CHECK

System administrators have to
check by various means whether
the daily backup is sucessfully
completed.

One way is to
maintain a short log file which
will log 4 or 5 lines everytime
the backup is completed.

The latest backup results will be
automatically checked by System
administrator on login, if he adds
these lines at the end of his
.profile file.

tail -5 /PATH/SHORT_LOG_FILE.log

GZIP ZNEW AND COMPRESS

GZIP ZNEW AND COMPRESS

In HP Unix "compress" command will compress
around 50 to 60%.  "gzip" will compress the
file upto 80%. There is a command available
in HP's unix to convert a compress file to
a zip file. "znew" will automatically
convert compressed files(*.Z) to gunzip
files(*.gz).

Example:
$ znew test.Z

THE BAD AND THE GOOD

THE BAD AND THE GOOD

I cringe anytime I see someone code inefficiently.  Here are
three of the most common mistakes, followed by a better way to
do the same thing.

Bad:    cat somefile | grep something
Better: grep something somefile
Why:    You're running one program (grep) instead of two (cat
and grep).

Bad:    ps -ef | grep something | grep -v grep
Better: ps -ef | grep [s]omething
Why:    You’re running two commands (grep) instead of three (ps
and two greps).

Bad:    cat /dev/null > somefile
Better: > somefile
Why:    You're running a command (cat) with I/O redirection,
instead of just redirection.

Although the bad way will have the same result, the good way is
far faster.  This may seem trivial, but the benefits will really
show when dealing with large files or loops.

RUN DAILY WITH AT

RUN DAILY WITH AT


UNIX provides a command called "at"
which can be used to run jobs according
to the specfied time.

To run a particular job in every hour,
every day use the following set of
commands in a file called "at.sh" which
will be executed recursively everyday.

########### CUT HERE ##################

#! /usr/bin/sh

# dt is a variable used to store
# current date

dt=`date | cut -c5-10`

# tm is a variable used to store
# current time

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

# "at" is the command ad -f is the
# option used to execute a specified
# file. "file Name" should be an
# executable file.

 at -f  ./"file Name" $tm $dt
 tm=`expr $tm + 1`
done

# With out manual intervention, automatic
# change over to the next day's job
# scheduling

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################

| grep myProcess ...","name":"RESTARTING PROCESSES"}; var fb_comment_action_link_132324981 = [{"href":"http://unixsaran.posterous.com/restarting-processes","text":"Read more on Posterous"}];