appended crontab entries with py script

Mike Meyer mwm at mired.org
Tue Sep 13 23:18:07 EDT 2005


rbt <rbt at athop1.ath.vt.edu> writes:

> How can I safely append a crontab entry to a crontab file
> progammatically with Python?

Well, one way would be to invoke the system crontab utility and use an
"editor" that passes the file to your program, and reads the results
back.

> I need to handle crontabs that currently have entries and crontabs that
> are empty. Also, I'd like this to work across Linux and BSD systems.
>
> Any pointers?

I think most Free Unix systems use the Vixie cron, and the non-free
ones have a "crontab" command (do some of them call it cron?) with the
same API. So you're pretty safe using that.

If you want to assume that you're going to have the vixie cron, you
could dig into it's guts to see what it does for locking, and do that
by hand.

   <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list