160 likes | 286 Views
Advance Unix. Service Management. There are plenty of GUI tools to control system startup scripts (/etc/init.d/*) The command line tool of choice is called chkconfig
E N D
Service Management • There are plenty of GUI tools to control system startup scripts (/etc/init.d/*) • The command line tool of choice is called chkconfig • chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories (see man chkconfig)
Service Management • To list all the services type chkconfig --list • This will display all the services and there status with each run level and you may want to pipe it to ‘less’ or ‘more’ • To modify or change the run level(s) for when the daemon or service is started type: chkconfig --level <runlevels> <service> on/off
Service Management • So to change the network service to run for levels 3 and 5 only type: chkconfig –level 35 network on • You can also add a service/daemon to your configuration using the –add switch chkconfig --add <service> • To turn a service off or on chkconfig <service> off or on
The “Super Daemon” • xinetd - the extended Internet services daemon (not to be confused with initd) • xinetd performs the same function as inetd: it starts programs that provide Internet services. • Instead of having such servers started at system initialization time, and be dormant until a connection request arrives, • xinetd is the only daemon started and it listens on all service ports for the services listed in its configuration file.
The “Super Daemon” • Benefits are: • Fewer running processes • Access control and logging (PAM) • logging control • log on success, failure, both • specify what is logged (user name, duration) • IMHO the book examples are not that good so here are some of mine: • sshd • cvs • rsync
The “Super Daemon” • /etc/xinetd.conf is the configuration file • /etc/xinetd.d is the directory where all the real info is. • Demo: /etc/xinet.d • Many security experts say you should shut down xinetd and delete the files from /etc/xinet.d -- this is if you are going to really lock down a server • One thing I will say – If you are not using it shut it down/turn it off.
rsync • rsync -avz dir1 node01:. • Option a stands for archive (preserve links and timestamps); v is for verbose and z is for data compression when sending-receiving. • In the case above, rsync was running in the clear • To run rsync over ssh, specify "-e ssh" option: • rsync -e ssh -avz dir1 node01:.
UNIX Scheduler System • The cron system is used to schedule commands to be executed periodically. • The name is derived from Greek chronos (χρόνος), meaning time. • The major components: • crond • crontab • at or batch • Generally, the schedules modified by crontab are enacted by a daemon, crond, • crond runs in the background • checks once a minute to see if any of the scheduled jobs need to be executed. • If so, it executes them. These jobs are generally referred to as cron jobs.
UNIX Scheduler System • The directories: • /etc/cron.d • /etc/cron.hourly • /etc/cron.daily • /etc/cron.weekly • /etc/cron.monthly • The files: • /etc/crontab • /etc/cron.deny • /var/spool/cron/<user-cron> • /etc/cron.allow • /etc/cron.deny
crontab and at commands • crontab commands: • List: crontab –l • Edit: crontab –e • Dump: crontab –l > cronfile • at commands • Edit: at or batch • List: atq • Remove: atrm
Crontab Fields • Minute 0-59 • Hour 0-23 • Day 1-31 • Month 1-12 • Weekday 0-6 (0=Sunday) * Matches everything 1-3 Matches range 1,5 Matches Series
Cron • Write your own Cron file • Format: • Minute Hour Day Month DayofWeek Command • Examples: • 10 0,4,8,12,16,20 * * * ping –c 60 www.yahoo.com • 0 22 * * 5 ./test.sh • Wildcard * for any entry • Comma , indicates multiple values (NO space inside) • Dash – indicate a range • 9-17: from 9am to 5pm • Slash / indicate stepped values • */2 : every 2 hour, minute…
at & batch • at: run command once at a specified time • For example: • at 2:00 • ./test.sh • Ctrl + d to exit • batch: run command once when system is idle • OS decides an appropriate time to run • Similar syntax as at
Crontab Exercise • See Handout or view online at: http://wildbill.org/rose/Spring07/sched_exercise.doc