can't get cron to run my script.
hi im trying to set up cron to execute a script every minute but im confused about the process. I read about the format of the crontab so im famialar with that. I read you can do crontab -e to edit your crontab but it defaults to vi. I tried to do export VISUAL='emacs" and that works but whenever i close out the shell and re-enter and try crontab -e again it goes back to opening it in vi. Is there a way to set it to emacs and have it stick? this is my crontab in /etc/
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly * * * * * jeff /home/jeff/appointmentreminder.sh when i first tried to do crontab -e it said i had a empty one for user so i tried creating one just adding the last line of the above crontab. this is what i get when i do crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.32647 installed on Tue Apr 12 16:58:38 2005) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 58 * * * * jeff /home/jeff/appointmentreminder.sh would i need to copy the SHELL, PATH, etc into that crontab as well for it to work? Any help would be appreciated. thanks in advanced. |
When I was setting up mine, I ran these commands:
export EDITOR=vi crontab /etc/crontab crontab -e When I want to edit the crontab, I just use the command: crontab -e So, I guess you would change your editor to emacs, try this: export EDITOR=emacs Quote:
* * * * * jeff /home/jeff/appointmentreminder.sh |
i forgot to change that. When i was testing it out i set it up to run the script the next minute. i did crontab /etc/crontab/ and that set it up right. doing the export EDITOR=emacs didn't work out for me it still opens up vi. in ps -A cron should be crond right? Cuz i thought maybe it wasn't starting because cron hadn't started.
|
I restart the crond after making changes: service crond restart
|
that still didn't work. i don't know if i have a certain version of cron/crontab because some of the cron related files i have weren't mentioned in some of the sites i read about cront/crontab. This is the output of ls /etc/ | grep cron
anacrontab cron.d cron.daily cron.hourly cron.monthly crontab crontab~ cron.weekly im not sure how to get the version numbers of either cuz i didn't see a -v or --version option |
I did a google for
linux "crontab -e" There was a similar message. The questioner wanted to know how to get 'crontab -e' to use vi instead of ed. The response was to get out of the habit of using 'crontab -e' because a slip-up could wipe out your crontab can cause all sorts of unpleasantness. He recommended: Quote:
So for you, use emacs instead of vi in the above example. |
thanks. yeah when i did use crontab -e i did have a sketchy feeling. I read another article about crontab and it says to add the scripts to the cron.weekly, cron.hourly, etc but then i don't understand how you'd find tune the extact time for each job. Or do you have to add it in that folder and the crontab entry fine tunes the time?
|
All times are GMT -5. The time now is 07:56 AM. |