You are not logged in.
Pages: 1
I'm a total noob when it comes to cron, and I have ready the wiki page and didn't see any relevant examples of doing this. I want to run a cron job once a month to create a file (touch /.readahead).
I have gathered I can put a script in /etc/cron.monthly and I have crond in my rc.conf. I'm a bit confused as to what I need to put in the script though. Would something like this be enough?
#!/bin/sh
touch /.readahead
Would I need to add anything else, would I need to use su or sudo in the script?
Last edited by bwat47 (2012-01-21 18:11:29)
Offline
You can use the @monthly call in crontab...
man crontab
# edit: the wiki page is good too https://wiki.archlinux.org/index.php/Cr … tab_format
Last edited by jasonwryan (2012-01-20 03:23:32)
Offline
Would I need to add anything else, would I need to use su or sudo in the script?
Short answer: No, any valid script is fine. However ...
If you save the script in /etc/cron.monthly it will be run by root (Check 'crontab -l' as root, you'll find the commands that execute those scripts), so if you want commands to be executed by another user you either put the script into their crontab with crontab -e or use su/sudo inside the script.
Stuff in /etc/cron.monthly will be executed whenever cron is running and more than one month has elapsed since it last ran. If you want to execute the script at a specific time/on a specific date, put the script directly into root's crontab (sudo crontab -e).
Last edited by lastchancetosee (2012-01-21 17:58:06)
My ship don't crash! She crashes, you crashed her!
Offline
Would I need to add anything else, would I need to use su or sudo in the script?
Short answer: No, any valid script is fine. However ...
If you save the script in /etc/cron.monthly it will be run by root (Check 'crontab -l' as root, you'll find the commands that execute those scripts), so if you want commands to be executed by another user you either put the script into their crontab with crontab -e or use su/sudo inside the script.
Stuff in /etc/cron.monthly will be executed whenever cron is running and more than one month has elapsed since it last ran. If you want to execute the script at a specific time/on a specific date, put the script directly into root's crontab (sudo crontab -e).
Thanks!
Offline
Pages: 1