Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-12-2005, 04:10 PM
|
#1
|
|
Member
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877
Rep:
|
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.
|
|
|
|
04-12-2005, 04:30 PM
|
#2
|
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
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:
|
58 * * * * jeff /home/jeff/appointmentreminder.sh
|
That will only run at the 58 minute of every hour. If you want it to run every minute use a *
* * * * * jeff /home/jeff/appointmentreminder.sh
|
|
|
|
04-12-2005, 04:49 PM
|
#3
|
|
Member
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877
Original Poster
Rep:
|
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.
|
|
|
|
04-12-2005, 04:52 PM
|
#4
|
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
I restart the crond after making changes: service crond restart
|
|
|
|
04-12-2005, 05:55 PM
|
#5
|
|
Member
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877
Original Poster
Rep:
|
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
|
|
|
|
04-12-2005, 06:10 PM
|
#6
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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:
Far safer is to use "crontab -l > somefile; vi somefile"
and then, if everything is to your liking, "crontab somefile"
|
http://aplawrence.com/Bofcusm/1281.html
So for you, use emacs instead of vi in the above example.
Last edited by jschiwal; 04-12-2005 at 06:11 PM.
|
|
|
|
04-12-2005, 06:34 PM
|
#7
|
|
Member
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877
Original Poster
Rep:
|
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?
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:50 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|