LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 04-12-2005, 04:10 PM   #1
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Rep: Reputation: 35
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.
 
Old 04-12-2005, 04:30 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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
 
Old 04-12-2005, 04:49 PM   #3
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Original Poster
Rep: Reputation: 35
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.
 
Old 04-12-2005, 04:52 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
I restart the crond after making changes: service crond restart
 
Old 04-12-2005, 05:55 PM   #5
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Original Poster
Rep: Reputation: 35
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
 
Old 04-12-2005, 06:10 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
Old 04-12-2005, 06:34 PM   #7
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Original Poster
Rep: Reputation: 35
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FTP Script will not run from Cron grhansen Programming 12 01-13-2006 04:13 AM
run shell script on cron varunbihani Linux - Newbie 5 07-08-2005 01:50 AM
howto run a script from cron every 5 minutes except 11pm-8am ? cccc Programming 2 03-20-2005 03:52 AM
How to write a script to run bitdefender antivirus as a cron job? ginda Linux - Software 1 03-10-2005 08:08 PM
shell script fo run auto job in cron JolynnMarie LinuxQuestions.org Member Intro 0 04-28-2004 11:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration