Thursday, December 22, 2011

Unix command to sort biggest size file in the directory

$du -sk * | sort -n

How to empty a Unix file system with cat /dev/null command dev null

First take the backup of existing file :

$cp dev_rd.log /sapcd/XVPdev


then empty the file

$cat /dev/null > dev_rd.log

still it was giving error : File exists.

It meant that noclobber option is set so gave command

$cat /dev/null >! dev_rd.log

and it worked

Thursday, December 8, 2011

Removing semaphores shared memory keys with ipcrm

Sometimes we are not able to remove the shared memory keys with cleanipc 52 remove command, we can find the culprit this way :

ipcs | grep crdadm | awk '{printf("ipcrm -s %s\n", $2);}'

or if we already have the error like that

Dec 8 10:52:08 root@globiz63 logpipe[16010]: (start_app crd0v 52 crdadm 1): OsKey: 25238 0x00006296 Semaphore Key: 38 remove failed **** - errno = 1 (Not owner)


you may find the cultprit by

## ipcs | grep 0x00006296

it will give the ownere as well

now log in as the owner and give the command

## ipcrm -s 687 (687 is the semaphore ID)

it should go now.