we all know you can use cron to run an applescript, but how would you use applescript to edit cron?
basically what I want to do is:
- create a cron entry if none exists
- read the entry if one exists
obviously i want to do this without using vi. so is the thing to do read the cron file (if so where is it?) or can you accomplish these things with do shell script and a cron command?
Thanks
Man cron and man crontab in terminal. They’ll tell you where to find the chrontabs (/var/cron/…). Modifying the files directly can make bad mojo. See man for explanation.
thanks. i read the man. and about the bad mojo. which is why i was asking how to do it properly.
let’s say you can GET the cron:
set result to do shell script “crontab -l”
then you parse it, making changes as necessary. how do y ou properly write it back?
it was suggested you can pipe the variable (of the changed cron) back to crontab -e, but i have no idea how to do that.
also, what about admin privs? i seem to be able to get crontab -l without authenticating, but i’m an admin user.