Web hosting service - The number returned is in kilobytes, which means
The number returned is in kilobytes, which means that the directory /usr/local uses about 15.1MB. Frequently, you’ll want to compare the output of this function to some value. For example, the following if statement checks to see whether more than 10,000KB are used by the directory /home/ranga/pub: if [ ” getSpaceSpace /home/ranga/pub ” -gt 10000 ] ; then printWARNING “You’re using to much space!” fi Obtaining the Process ID by Name One of the difficulties with the ps command is that it is hard to obtain the process ID of a command by specifying only its name. In shell scripts that have to start and stop processes, the capability to look through the output of ps and retrieve a list of process IDs based on a command’s name is essential. In this section, I will present a function that displays a list of process IDs (pids) based on a string supplied by the user. ################################################ # Name: getPID # Desc: outputs a list of process id matching $1 # Args: $1 -> the command name to look for ################################################ getPID() { if [ $# -lt 1 ] ; then printERROR “Insufficient Arguments.” return 1 fi PSOPTS=”-ef” /bin/ps $PSOPTS | grep “$1″ | grep -v grep | awk ‘{ print $2; }’ } As you can see, this function is a set of filters on top of the command /bin/ps -ef. The first grep command looks for all lines that match the first argument. As an example, executing this on the command line produces output similar to the following: $ /bin/ps -ef | grep sshd Here you are looking for all the lines that contain the word sshd. The output should look similar to the following: root 1449 1 8 12:23:06 ? 0:02 /opt/bin/sshd ranga 1451 944 5 12:23:08 pts/t0 0:00 grep sshd As you can see, the output contains two lines. The first one contains the process ID of the commands that you are looking for, but the second contains the process ID of the grep command that just executed. In order to get rid of such lines, add the grep -v grep to the pipeline.
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.