Monday, August 17, 2009

processe in Linux

Background Process
Unlike with a foreground process, the shell does not have to waitfor a background process to end before it can run more processes.Within the limit of the amount of memory available, you can enter manybackground commands one after another. To run a command as a backgroundprocess, type the command and add a space and an ampersand to the endof the command. For example:
$ command1 &
Immediately after entering the above command, the shell willexecute the command. While that is running in the background, the shellprompt (% for the C Shell, and $ for the Bourne Shell and the KornShell) will return.
Sponsored Links
Linux Development ToolsEmbedded Linux development tools on the web for your processorwww.TimeSys.com
Run Visio on LinuxNo Windows OS license required. Try free trial of CrossOver Linux!www.CodeWeavers.com
AIX,SUN,Linux,Useful LinkCollection of unix documents listed based on flavours of unix.www.FantasticUnix.comAt this point, you can enter another command for eitherforeground or background process. Background jobs are run at a lowerpriority to the foreground jobs.
You will see a message on the screen when a background process is finished running.
Foreground Process Work
A foreground process is different from a background process in two ways:
1. Some foreground processes show the user an interface, through which the user can interact with the program.2. The user must wait for one foreground process to complete before running another one.
To start a foreground process, enter a command at the prompt, e.g.,
$ command1
The next prompt will not appear until command1 finishes running.Definition: child process: A process createdby another process (the parent process). Each process may create manychild processes but will have only one parent process, except for thevery first process which has no parent. The first process, called initin Linux, is started by the kernel at boot time and never terminates.From Linux Guide @FirstLinuxDefinition: process (process ID, PID): Allsoftware runs within an operating system concept known as a process.Each program running on a system is assigned its own process ID (PID).Users can easily obtain a process list (using Task Manager on Windowsor ps on UNIX) in order to see what is running. Key point: Trojans,rootkits, and other evil software will attempt to hide themselves fromthe process list, either by providing replacements to the programs thatlist processes (like ps), or by hooking the system calls that enumerateprocesses.Acrontabfile contains instructions to thecron(8)daemon of the general form: ``run this command at this time on this date''.Each user has their own crontab, and commands in any given crontab will beexecuted as the user who owns the crontab. Uucp and News will usually havetheir own crontabs, eliminating the need for explicitly runningsu(1)as part of a cron command.
Blank lines and leading spaces and tabs are ignored. Lines whose firstnon-space character is a pound-sign (#) are comments, and are ignored.Note that comments are not allowed on the same line as cron commands, sincethey will be taken to be part of the command. Similarly, comments are notallowed on the same line as environment variable settings.
An active line in a crontab will be either an environment setting or a croncommand. An environment setting is of the form,
name = value
where the spaces around the equal-sign (=) are optional, and any subsequentnon-leading spaces invaluewill be part of the value assigned toname.Thevaluestring may be placed in quotes (single or double, but matching) to preserveleading or trailing blanks.
Several environment variables are set upautomatically by thecron(8)daemon.SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd line of the crontab's owner.HOME and SHELL may be overridden by settings in the crontab; LOGNAME may not.
(Another note: the LOGNAME variable is sometimes called USER on BSD systems...on these systems, USER will be set also.)
In addition to LOGNAME, HOME, and SHELL,cron(8)will look at MAILTO if it has any reason to send mail as a result of runningcommands in ``this'' crontab. If MAILTO is defined (and non-empty), mail issent to the user so named. If MAILTO is defined but empty (MAILTO=""), nomail will be sent. Otherwise mail is sent to the owner of the crontab. Thisoption is useful if you decide on /bin/mail instead of /usr/lib/sendmail asyour mailer when you install cron -- /bin/mail doesn't do aliasing, and UUCPusually doesn't read its mail.
The format of a cron command is very much the V7 standard, with a number ofupward-compatible extensions. Each line has five time and date fields,followed by a user name if this is the system crontab file,followed by a command. Commands are executed bycron(8)when the minute, hour, and month of year fields match the current time,andwhen at least one of the two day fields (day of month, or day of week)match the current time (see ``Note'' below).Note that this means that non-existant times, such as "missing hours"during daylight savings conversion, will never match, causing jobsscheduled during the "missing times" not to be run. Similarly, timesthat occur more than once (again, during daylight savings conversion)will cause matching jobs to be run twice.
cron(8)examines cron entries once every minute.
The time and date fields are:
field allowed values----- --------------minute 0-59hour 0-23day of month 1-31month 1-12 (or names, see below)day of week 0-7 (0 or 7 is Sun, or use names)
A field may be an asterisk (*), which always stands for ``first-last''.
Ranges of numbers are allowed. Ranges are two numbers separatedwith a hyphen. The specified range is inclusive. For example,8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10and 11.
Lists are allowed. A list is a set of numbers (or ranges)separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''.
Step values can be used in conjunction with ranges. Followinga range with ``/'' specifies skips of the number's valuethrough the range. For example, ``0-23/2'' can be used in the hoursfield to specify command execution every other hour (the alternativein the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps arealso permitted after an asterisk, so if you want to say ``every twohours'', just use ``*/2''.
Names can also be used for the ``month'' and ``day of week''fields. Use the first three letters of the particularday or month (case doesn't matter). Ranges orlists of names are not allowed.
The ``sixth'' field (the rest of the line) specifies the command to berun.The entire command portion of the line, up to a newline or %character, will be executed by /bin/sh or by the shellspecified in the SHELL variable of the cronfile.Percent-signs (%) in the command, unless escaped with backslash(\), will be changed into newline characters, and all dataafter the first % will be sent to the command as standardinput.
Note: The day of a command's execution can be specified by twofields --- day of month, and day of week. If both fields arerestricted (ie, aren't *), the command will be run wheneitherfield matches the current time. For example,``30 4 1,15 * 5''would cause a command to be run at 4:30 am on the 1st and 15th of eachmonth, plus every Friday.
EXAMPLE CRON FILE# use /bin/sh to run commands, no matter what /etc/passwd saysSHELL=/bin/sh# mail any output to `paul', no matter whose crontab this isMAILTO=paul## run five minutes after midnight, every day5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1# run at 2:15pm on the first of every month -- output mailed to paul15 14 1 * * $HOME/bin/monthly# run at 10 pm on weekdays, annoy Joe0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"5 4 * * sun echo "run at 5 after 4 every sunday"
Post a Comment

You might also like :

Related Posts with Thumbnails