07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SECURITY<br />

Restricting cron or atd<br />

You can restrict access to cron by creating an explicit authorization file<br />

(whitelist) in /etc/cron.allow, in which you indicate the only users authorized<br />

to schedule commands. All others will automatically be deprived of<br />

this feature. Conversely, to only block one or two troublemakers, you could<br />

write their username in the explicit prohibition file (blacklist), /etc/cron.<br />

deny. This same feature is available for atd, with the /etc/at.allow and<br />

/etc/at.deny files.<br />

The root user has their own crontab, but can also use the /etc/crontab file, or write additional<br />

crontab files in the /etc/cron.d directory. These last two solutions have the advantage of being<br />

able to specify the user identity to use when executing the command.<br />

The cron package includes by default some scheduled commands that execute:<br />

• programs in the /etc/cron.hourly/ directory once per hour;<br />

• programs in /etc/cron.daily/ once per day;<br />

• programs in /etc/cron.weekly/ once per week;<br />

• programs in /etc/cron.monthly/ once per month.<br />

Many Debian packages rely on this service, they put maintenance scripts in these directories,<br />

which ensure optimal operation of their services.<br />

9.7.1. Format of a crontab File<br />

TIP<br />

Text shortcuts for cron<br />

cron recognizes some abbreviations which replace the first five fields in a<br />

crontab entry. They correspond to the most classic scheduling options:<br />

• @yearly: once per year (January 1, at 00:00);<br />

• @monthly: once per month (the 1st of the month, at 00:00);<br />

• @weekly: once per week (Sunday at 00:00);<br />

• @daily: once per day (at 00:00);<br />

• @hourly: once per hour (at the beginning of each hour).<br />

SPECIAL CASE<br />

cron and daylight savings<br />

time.<br />

In Debian, cron takes the time change (for Daylight Savings Time, or in fact for<br />

any significant change in the local time) into account as best as it can. Thus,<br />

the commands that should have been executed during an hour that never<br />

existed (for example, tasks scheduled at 2:30 am during the Spring time change<br />

in France, since at 2:00 am the clock jumps directly to 3:00 am) are executed<br />

shortly aer the time change (thus around 3:00 am DST). On the other hand,<br />

in autumn, when commands would be executed several times (2:30 am DST,<br />

then an hour later at 2:30 am standard time, since at 3:00 am DST the clock<br />

turns back to 2:00 am) are only executed once.<br />

Chapter 9 — Unix Services<br />

205

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

Saved successfully!

Ooh no, something went wrong!