Title: Les 5
1Les 5 Processes
2Processes inside out
- Multi-user and multi-tasking
- Linux is based on UNIX, where it has been common
policy to have multiple users running multiple
commands, at the same time and on the same system
3Daemons
- Daemons are server processes that run
continuously. Most of the time, they are
initialized at system startup and then wait in
the background until their service is required. A
typical example is the networking daemon, xinetd,
which is started in almost every boot procedure.
After the system is booted, the network daemon
just sits and waits until a client program, such
as an FTP client, needs to connect
4Job control
regular_command - Runs this command in the
foreground. command - Run this command in the
background (release the terminal) jobs - Show
commands running in the background. CTRLZ -
Suspend (stop, but not quit) a process running in
the foreground (suspend). CTRLC -
Interrupt (terminate and quit) a process running
in the foreground. n - Every process running in
the background gets a number assigned to it. By
using kill - End a process (also see Shell
Builtin Commands in the Info pages of bash)
5Display job information
- Ps
- Top
- Ps axjf (for tree mode)
6Boot proces
- BIOS (POST)
- MBR
- Grub/Lilo
- Init (father of all processes)
- spawns all other processes.
- It runs as a daemon and typically has PID 1.
- /etc/inittab (sets the runlevels)
7Runlevels
- 0 - halt (Do NOT set initdefault to this)
- 1 - Single user mode
- 2 - Multiuser, without NFS (The same as 3, if
you do not have networking) - 3 - Full multiuser mode
- 4 - unused
- 5 - X11
- 6 - reboot (Do NOT set initdefault to this)
8Shutdown / reboot
- Shutdown -h now (immediately) or halt
- Shutdown -r now (reboot)
- Reboot
- Init ltrunlevelgt
9Priority
- Nice (-20 (best) to 19 (least))
- Renice (same as nice, but for running procs )
10Scheduling processes
- Use idle time !
- Sleep
- At (The at command executes commands at a given
time) - Crontab (easy scheduling)
11Cron and crontab
- The cron system is managed by the cron daemon. It
gets information about which programs and when
they should run from the system's and users'
crontab entries. - Only the root user has access to the system
crontabs - While each user should only have access to his
own crontabs. On some systems (some) users may
not have access to the cron facility.
12/etc/crontab
root_at_TBE1ID980168 cat /etc/crontab
/etc/crontab system-wide crontab Unlike any
other crontab you don't have to run the
crontab' command to install the new version
when you edit this file and files in
/etc/cron.d. These files also have username
fields, that none of the other crontabs
do. SHELL/bin/sh PATH/usr/local/sbin/usr/local
/bin/sbin/bin/usr/sbin/usr/bin m h dom mon
dow user command 17 root cd /
run-parts --report /etc/cron.hourly 25 6
root test -x /usr/sbin/anacron ( cd /
run-parts --report /etc/cron.daily ) 47 6
7 root test -x /usr/sbin/anacron ( cd /
run-parts --report /etc/cron.weekly ) 52 6 1
root test -x /usr/sbin/anacron ( cd /
run-parts --report /etc/cron.monthly )
13Crontab usage
- Crontab -l
- Crontab -e
- Kill -HUP ltcron-pidgt (deprecated)
14Summary (1)
15Summary (2)