1826400 Members
4670 Online
109692 Solutions
New Discussion

some questions in unix

 
SOLVED
Go to solution
subrata  Sur
Frequent Advisor

some questions in unix

Can any one tell me
a)what is the maximum entry given in crontab

b)how many conjobs can run at a time

c)How to Schdule Jobs in Unix apart from cronjobs eg,A command to be executed at 12 hrs on every Monday what is the other method to schedule this apart from cronjobs...

How many job schedulers are available in unix.
Which one you will prefer?

d)How do you see child processes of a given process? otherwise the parent process and all child process ? how can i kill child as well as parant process ?
How do you kill all the child processes of a parent process?
e)
How to see a growing trace file?
f)How do u increase the priority of a process ?
g)
How to list only the directories in current directory ?
ls -d is not work ....
uacob004 $ ls -d
.
h)
What is sticky bit ?
i)How to replace the control characters (say ^M) from a file ?
j)
How to know the current shell version ?
How you will find out which shell i m working ?
ja)How do u come to know any commands in unix executed or not.How do you come to know whether the last process executed successfully or not
k)
What's the default and first shell ?
l)
How to make sure that the oracle session opened within a shell script will automatically get closed when process is killed at the unix side.
m)
what is nohup ? what is difference between nohup and &(ampersand)?
n)
How to rename a string in file from command promt
o)
How to move value in $10 to $9?

Thanx in advance If u have answer any one of this query ...
With regards,
Subrata

16 REPLIES 16
Rodney Hills
Honored Contributor
Solution

Re: some questions in unix

Is this a test from a class you are taking?

Do you get a point for every right answer?

Speaking of points... I notice you haven't assigned points to any of your previous posts.

e) tail -f tracefile
f) "nice" command
g) ll | grep "^d"
h) Sticky bit use to mean keep an executable in memory, but now it is used on directories to only allow owner to modify/delete a file
i) tr -d "[:graph:]" outfile
j) what /usr/bin/sh
ja) varitalb $? has exit value of last command
k) entry in /etc/passwd to use when user logs on
m) "nohup" keeps a background session active even if the launching session exits. "&" used to define a process to run in the background.
n) sed -e 's/string1/string2/g' outfile
o) shift command

HTH

-- Rod Hills
There be dragons...
Leif Halvarsson_2
Honored Contributor

Re: some questions in unix

Hi,

many questions, some answeres.

a. don't remember if there is any limitations. I have never seen any problem.
c. cron, at
f. nice, rtprio (use with caution)
g. "find . -type d"
i. see man page for tr. \ can be used
k. I don't know if it is correct to call "Default" but, Posix shell is the standard HP-UX shell.
m. nohup is normally used together with &. makes the process imine to logout
n. sed
o. shift
Robert-Jan Goossens
Honored Contributor

Re: some questions in unix

Hi,

I will start at the beginning, I hope others will fill in the blanks :-)

A+B

# cat /var/adm/cron/queuedefs

wil give you the cron definitions.

something like

a.4j1n
b.2j2n90w
c.10j2n

"c" << the "c" queue, for cron jobs
"10j" << 10 cron jobs can be running simultaneously
"2n" << jobs will run at a nice value of 2

C

At is an other cronlike command.

J
# echo $shell

Ja, depends how you write your scripts.

H posix shell and korn shel (sh and ksh) root is strongly adviced to use the posix shell.

Robert-Jan
A. Clay Stephenson
Acclaimed Contributor

Re: some questions in unix

I will not encourage or reinforce laziness. Do some research on your own first then ask targeted questions. For example, a) and b) can both be answered by a simple "man cron". The cron man page will in turn lead you to this queuedefs man page. This is a "stickey-bit" for me.
If it ain't broke, I can fix that.
subrata  Sur
Frequent Advisor

Re: some questions in unix

Thanx again for ur reply

i have a confusion of this question as some of the answer i dont know and some i still have confusion ...

a) i have checked queuedefs command in crontabs it is q.[njobj][nicen][nwaitw]

njob The maximum number of jobs that can be run simultaneously in that queue. Although any number can be specified here, the total number of jobs that can be run on all the queues is limited to 100.

so i guess the 100 cron jobs will be submit at a time if I m wrong plz correct me


Alex Lavrov.
Honored Contributor

Re: some questions in unix

I'm with Clay.
"man" and "google" will do the job in 3 minutes.

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
A. Clay Stephenson
Acclaimed Contributor

Re: some questions in unix

Now that's a better question. The maximum number of jobs that can be run by cron at any one time is 100. This does not mean that one can't have thousands of cron jobs just so long as no more than 100 are running at any one time. Of course, any one cron job could in turn actually execute many, many processes --- all at the same time (more or less) by placing the commands in background via the ampersand (&) or by having them run serially by not placing the processes in background.
If it ain't broke, I can fix that.
Raj D.
Honored Contributor

Re: some questions in unix

Hi Subrata,

c) at , and own scripts , apart from cron.
d) ps -ef , kill -9
f) with nice command
g) ls -l | grep dr
h) to set special permission, every one can access and wrtie , but not delete.
i) with dos2ux command , or with awk and tr command.
j) echo $? [ Return 0 , for if the last command is successful ]
k) on hp-ux defaule shell is POSIX . /usr/bin/sh
m) nohup -> ro run a command in background even user logs out, or hangsup. Ampersand --> kills the process when logsout.
n) to rename a string from a command prompt use sed command. $ sed 's/old/new/' filename1 > filename2
o) $9="`echo $10`"

Enjoy ,
Cheers,
Raj
" If u think u can , If u think u cannot , - You are always Right . "
Alan Meyer_4
Respected Contributor

Re: some questions in unix

I'll do a few

e) tail -f trace_file
g) ls -l |grep '^d'
o) shift
" I may not be certified, but I am certifiable... "
subrata  Sur
Frequent Advisor

Re: some questions in unix

b) we have two job scheduler one through crontab ,another "at" or "batch "
which one we have to prefer if i have to submit a job ... Is there any criteria / significance for using this job scheduler


d)How do you see child processes of a given process? otherwise the parent process and all child process ? How do you kill all the child processes of a parent process?

ps -ef give all my listing of processes How i know which one have is the parent processes and what is the child processes for that ...

f) i m use command nice -1 <>
if already the process is running Can i increase the prioriry by checking the process (by ps -ef ) is there any other effect ...

ja)How do u come to know any commands in unix executed or not.How do you come to know whether the last process executed successfully or not
Tried varitalb $? But it is not working ....
Thanx again for ur reply ....

With regards,
subrato





Alan Meyer_4
Respected Contributor

Re: some questions in unix

B) AT is a one shot schedule of a job, cron sets the job to run at regularly scheduled intervals
" I may not be certified, but I am certifiable... "
Alan Meyer_4
Respected Contributor

Re: some questions in unix

D) under SAM>Process Management>Process Control, the display is sorted so as to list all child processes under the parent process
" I may not be certified, but I am certifiable... "
A. Clay Stephenson
Acclaimed Contributor

Re: some questions in unix

To find the child processes of a given parent process, write a script similar to this:

#!/usr/bin/sh

PPID=${1}
shift
ps -ef | awk -v ppid=${PPID} '{if (($3 + 0) == ppid print}'

Use it like this:
my.sh 6097 # to find all child processes of PID 6097


The status of the last executed command is ${?} BUT you must capture it immediately because the next command will alter it.
e.g.

ls -l /rrr/ggg
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "Okay"
else
echo "Bad"
fi

Note: The exit status of MOST processes use 0 to indicate success but that status is the whim of the programmer.
If it ain't broke, I can fix that.
Alan Meyer_4
Respected Contributor

Re: some questions in unix

ja) the exit status of a command is stores in the $? variable. $? = 0 if it was successful.
" I may not be certified, but I am certifiable... "
A. Clay Stephenson
Acclaimed Contributor

Re: some questions in unix

Ooops that should be:

PPID=${1}
shift
ps -ef | awk -v ppid=${PPID} '{if (($3 + 0) == ppid) print}'

and yes, the ($3 + 0) was intentional.
If it ain't broke, I can fix that.
Bill Hassell
Honored Contributor

Re: some questions in unix

To see the parent/child relationship of all processes, use ps with the UNIX95 variable set as in:

UNIX95=1 ps -eH

You can limit the listing to a given user login:

UNIX95=1 ps -fHu user-name

man ps for a lot of details


Bill Hassell, sysadmin