Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Understanding OS X's cron
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Understanding OS X's cron



Hello listers. Here I am again with my backup chores novel, this time trying to implement the final stages in order to commit everything to the main server. A few days ago I posted a script that I want to execute daily off of cron but I'm having some problems understanding how OS X deals with that last player. According to the man pages OS X uses Vixie Cron, with user crontabs located in /var/cron/tabs/ and the main crontab file living in /etc/crontab. According to cron(8) the format of /etc/crontab is different from that used in the users' crontabs (it includes a user field), so I am assuming I should stick to the latter, right?

Anyhow, I want my script to run from Monday to Friday at 11:00 p.m. Will the following crontab work for that?

##
# Personal crontab file.
##
SHELL=/bin/sh
HOME=/var/log
MAILTO=""
#
#minute hour mday month wday command
0 23 * * 1-5 ~/Library/bin/FMBackUp_local.sh

That was installed through "crontab -e" from my admin account, which means the command will be executed by user "juan". What if I wanted it to execute as root? Will the following:

crontab -u root -e

let me edit and install a crontab for root, so that the appropriate command executes with super powers? Is this advised? Currently, despite the existence of /etc/crontab (which lists "root" as the user to execute the periodic commands), "sudo crontab -lu root" says there's no crontab for root. Is this to be expected if we consider that /etc/crontab doesn't precisely belong to root? Should I fix the absence of the "allow" and "deny" files? Do they have a particular syntax or just a line by line list of users?

What does the "MAILTO" declaration exactly do? My script executes some actions and passes them to a home grown log which I intend to mail to myself in the future. I really don't think cron has the ability to pick that up from the script, grab the log for me and mail it... What does it mail then, some kind of exit status or error reports (provided, of course, a working mail server is in place)?

Boy, this email is full of questions! The last one... ones... how does cron handle the "SHELL" declaration? My script has an sh shebang (#!/bin/sh), will that conflict in any way with the declaration, like a double call to sh or something like that? Does the shebang override "SHELL"? What if I wanted to run a perl script or a tcsh one with the appropriate shebangs?

Well, if I get those doubts sorted out I'd be ready to go. Thank you all again in advance for your time and help!

Sincerely,...


Juan.
_______________________________________________
macos-x-server mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macos-x-server
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.