8/20/10

Command of The Month - #top

USAGE: #top


-Displays CPU processes in real-time. It also displays the PID, command for that program, memory usage, active users... 





The following are some options that can be used with top.

-i    ignores any idle processes.

-p   monitors a process given it's PID.

-n   updates the display 'n' number of times then exits.
      usage: #top -n 5



**For more in-depth information about top refer to the man pages.

Chkconfig Tool

chkconfig provides a simple command-line tool for activating and deactivating services. It is used for managing the collection of symlinks in /etc/rc[0-6].d directories.

By simply typing chkconfig under root privileges you can see the list of services available indicating the init level the service is on for.

[root@localhost ~]# chkconfig

NetworkManager   0:off 1:off 2:on 3:on 4:on 5:on 6:off

abrtd                      0:off 1:off 2:off 3:on 4:off 5:on 6:off

acpid                      0:off 1:off 2:on 3:on 4:on 5:on 6:off

atd                          0:off 1:off 2:off 3:on 4:on 5:on 6:off


The following is an example disabling the bluetooth service on startup. This allows for computers like mine who don't have bluetooth the need for the PC to start the service.

#chkconfig bluetooth off
#chkconfig

bluetooth 0:off 1:off 2:off 3:off 4:off 5:off 6:off



**For more in-depth information using chkconfig refer to the man pages.

Using the Crontab utility

Cron is a scheduler for Unix and Linux OS' which can run commands or shell scripts automatically at a specific time.

Scheduling commands, shell scripts, or other programs to be ran automatically are contained in the file called:

/etc/crontab

This file contains jobs that are to be run automatically using a specific format. The cron utility is used to create, edit, and remove that file.

# Example of job definition:

# .---------------- minute (0 - 59)

# | .------------- hour (0 - 23)

# | | .---------- day of month (1 - 31)

# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...

# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# | | | | |

# * * * * * command to be executed


The following is an example of a job scheduled in the crontab to automatically run a script every 5 hours during the week.

0   5   *   *   1-5   /home/documents/script

Or, check every minute for logins by user “Joe”

*   *   *   *   *    who | grep '^Joe'

Cron can also direct programs to be executed in directories for an hourly, daily, weekly, monthly basis. To do this, the crontab would have scheduling instructions to run commands contained in special subdirectories such as /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly, etc. This allows admins to just add programs to those directories. Making it even more easy to manage.