170 likes | 280 Views
Process Management. Assignment Issues. Command line parameters References. What is a process?. An application that does something ls or the start button, etc. Types of OS’s. Single tasking Batch Multiprogramming Multitasking Multithreaded Linux is Multi-tasking and Multi-threaded.
E N D
Assignment Issues • Command line parameters • References
What is a process? • An application that does something • ls or the start button, etc
Types of OS’s • Single tasking • Batch • Multiprogramming • Multitasking • Multithreaded Linux is Multi-tasking and Multi-threaded
Monitoring process in Linux • ps – snapshot of running processes • top – interactive ps, updates periodically • “System Monitor” – GUI version of top
Background processes • Two ways to create • Command followed by & • df –k & • Ctrl-Z in an interactive command
Terminating processes • Three ways: • Ctrl-C – only works on foreground CLI processes • Kill command – kill -15 1234 • kill <signal> <pid> • 15 – means “please go away” • 9 – “go away now” • Others – depends on application • killall – only root can run, also linux specific
When do processes run? • Kernel Daemons/Background (&ed commands) • Scheduled by the kernel • Now • Commands in the CLI • Clicks in the GUI • Later • at • batch • cron
at • One time scheduling • Basic Syntax: • at –f <command> <time> • Command has to be a shell script, don’t forget to add the execute bit! • /etc/at.allow – users allowed to use at • No at.allow means all users • /etc/at.deny – users not allowed to use at
batch • Sort of like at, but not time based, runs on load
Other at commands • atq – shows what’s in your at queue • atrm – allows you to remove queued at jobs
cron • Schedules jobs at specific times and dates • /etc/cron.allow – users allowed to use cron • No cron.allow means all users • /etc/cron.deny – users not allowed to use cron • 2 ways to schedule • Files in /var/spool/cron (called crontabs) • /etc/cron.*
crontabs • Edit them via crontab –e • 1 job per line: 10 3 * * * /usr/sbin/logadm • * does not mean 1, it means ALL
Crontab time fields • field allowed values • ----- -------------- • minute 0-59 • hour 0-23 • day of month 1-31 • Month 1-12 • day of week 0-7
/etc/cron.* • Directories in /etc • /etc/cron.hourly • /etc/cron.daily • /etc/cron.weekly • /etc/cron.monthly • Copy script into appropriate directory • Want something daily and hourly, must be in both
Cron gotchas! • at/batch inherit your current shell environment, cron DOES not • Don’t forget to chmod +x your scripts • Don’t hand edit the crontab files, always use crontab –e • By default, all three send email to user who scheduled