Unix ps command – Long Process Listing

| Posted by watashii | Filed under Programming, Unix

When viewing full process listings with ps -ef command, sometimes the command name is too long and gets chopped off at the end of the screen. This command name has a limit of 80 characters.

netcool@sun61 [/opt/netcool] 688 % ps -ef|grep 6176
netcool 6176 1 0 Sep 12 ?  31:55 /opt/netcool/platform/solaris2/jre_1.5.0/bin/java -Xmx1024m -Xms256m -Djava.awt

So how can we show the entire command? The solution is to use the /usr/ucb/ps -auxxwww command:

netcool@sun61 [/opt/netcool] 689 % /usr/ucb/ps -auxxwww|grep -i 6176
netcool   6176  0.1 10.5610440428552 ?  R   Sep 12 31:55 /opt/netcool/platform/solaris2/jre_1.5.0/bin/java -Xmx1024m -Xms256m -Djava.awt.headless=true -Dnchome=/opt/netcool -Dngfhome=/opt/netcool/guifoundation -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dbase.directory=/opt/netcool -Dsm.props.directory=/opt/netcool/etc/sm -Djava.security.auth.login.config=/opt/netcool/guifoundation/conf/mach_jaas.config -Djava.endorsed.dirs=/opt/netcool/guifoundation/common/endorsed -classpath /opt/netcool/platform/solaris2/jre_1.5.0/lib/tools.jar:/opt/netcool/guifoundation/bin/bootstrap.jar -Dcatalina.base=/opt/netcool/guifoundation -Dcatalina.home=/opt/netcool/guifoundation -Djava.io.tmpdir=/opt/netcool/guifoundation/temp org.apache.catalina.startup.Bootstrap start

Tags: ,

UNIX file size listing – du command

| Posted by watashii | Filed under Programming, Unix

Question: How can I list the true file and directory sizes on UNIX?

boadmin@nshost1>$ ls -la
total 12130522
drwxr-xr-x   5 boadmin  boadmin      512 Aug  4 14:30 .
drwxr-xr-x  31 boadmin  boadmin     1024 Aug  1 22:00 ..
drwxr-xr-x   5 boadmin  boadmin      512 May  7 05:48 DISK_1
drwxr-xr-x   3 boadmin  boadmin      512 May  7 05:47 DISK_2
drwxr-xr-x   3 boadmin  boadmin      512 May 31 14:02 sp3
-rw-r--r--   1 boadmin  boadmin  6207767040 Aug  4 14:33 sp3.tar

Read the rest of this entry »

Tags: , , , ,

Unix – Creating Cron Jobs with Crontab

| Posted by watashii | Filed under Programming, Unix

Cron is a Unix (*nix) utility for scheduling tasks to run in the background.   These are known as cron jobs.  A crontab is basically a text file (cron table) containing a list of commands to be run, under the current logged-in user.

  1. Commands
    crontab -e   # Edit (or create) the crontab file
    crontab -l   # View the crontab file
    crontab -r   # Remove the crontab file
  2. Restrictions
    Crontab access is controlled with a cron.allow and a cron.deny file, listing the associated usernames.  If cron.deny exists, and cron.allow is missing, all users can use crontab.  If both missing then only root is allowed.
    whereis cron
  3. Crontab file syntax
    The syntax contains 5 fields specifying the scheduling datetime values, and the last portion contains the Unix command to run.
    # +---------------- minute (0 - 59)
    # | +------------- hour (0 - 23)
    # | | +---------- day of month (1 - 31)
    # | | | +------- month (1 - 12)
    # | | | | +---- day of week (0 - 7) (Sunday=0 or 7)
    # | | | | |
      * * * * * command to be executed

    On each of the 5 fields, 3 operators can be used to specify the datetime selection.
    # Comma (',') specifies a list of values, eg: "1,3,4,7"
    # Dash ('-') specifies a range, eg: "1-3" or "1,2,3"
    # Asterisk ('*') specifies all possible values for a field.
  4. Crontab file example
    The following job lists the tmp directory structure and appends the output to a log file every minute.
    0-59 * * * *  ls -la /tmp >> /tmp/log.txt

Tags: , , , ,