16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Unix</strong> Administration<br />

for (i=0; i&i<br />

done<br />

Sync<br />

The superblock exists both in memory and on disk.<br />

The "sync" command flushes memory to disk. This is done by <strong>the</strong> kernel or /etc/update at regular intervals.<br />

#define TRUE 1<br />

main() /* update.c */<br />

{<br />

while (TRUE) {<br />

sync(); sleep(30);<br />

}<br />

}<br />

Cron<br />

Cron - from <strong>the</strong> greek "chronos" meaning "time".<br />

/etc/cron executes commands at specified dates and times. Regularly scheduled commands can be specified by<br />

instructions in /etc/crontab. Cron is started by /etc/rc at boot time and from <strong>the</strong>n on wakes up each minute to<br />

determine if any commands are scheduled to be run.<br />

/etc/crontab record fields:<br />

- minute (0-59),<br />

- hour (0-23),<br />

- day of month (1-31),<br />

- month of year (1-12),<br />

- day of week (0-6 <strong>with</strong> 0=Sunday),<br />

- command-to-execute<br />

Any of <strong>the</strong> time fields can be a pattern.<br />

Examples:<br />

Automatically shutdown at 8am each Friday<br />

0 8 * * 1 /etc/shutdown "shutting down for backup"<br />

Order some milk at midnight every Monday - Friday<br />

0 0 * * 1-5 echo "I need more milk" | mail milkman<br />

Run suidcheck every 20 minutes Mon-Fri, 9am - 5pm<br />

0, 20, 40 9-16 * * 1-5 suidcheck<br />

0 17 * * 1-5 suidcheck<br />

Printing<br />

$ lpr filename # BSD<br />

$ lp filename # System V<br />

A "spooler" is a method of buffering data on its way to a specific destination. i.e. hold files to be printed until line<br />

printer is ready to process <strong>the</strong>m.<br />

A "daemon" program wakes up to do <strong>the</strong> task when required, and <strong>the</strong>n goes back to sleep again. These daemons<br />

reside in /usr/lib or /etc called lpd (BSD) or lpsched (SYS V).<br />

! BSD printing<br />

195

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!