LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-30-2007, 09:31 AM   #1
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Rep: Reputation: 15
how to set change crontab editor?


Hi.

Can anyone tell me how I change the cron editor? At present it's set to vim, which I never learned, and always ties me up in knots!

thanks
 
Old 03-30-2007, 09:47 AM   #2
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Original Poster
Rep: Reputation: 15
Oops....should have ran a search for this before posting!

Code:
export EDITOR="/path/to/preferred/editor"
in .bashrc will do it
 
Old 03-30-2007, 09:54 AM   #3
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Original Poster
Rep: Reputation: 15
but I do have another question....

the job I'm setting to run requires input files that have to be in the current directory...but you don't specify the directory to run the job from with the crontab command...so I've changed to the relevant directory and set the crontab -e command there...will this ensure that it runs from that directory?

thanks
 
Old 03-30-2007, 10:14 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
No, it won't. The jobs are typically run from the user's home directory.
Adding the PWD environment variable (ie PWD=/path/to/proper/directory at the top of the crontab settings) may help, but I'm not sure it'll work.

Why not have your program cd to the appropriate directory first? ie wrap it in a script (or modify it, if it's a script) that looks something like this:
Code:
#!/bin/bash
#directory to run from:
dir='/path/to/directory/';
cd ${dir}
#make sure that the "cd" has worked properly
if (( $? != 0 )); then
echo "Error: failed to change directory to ${dir}."; 
exit 1;
fi;
/path/to/your_program
Or, better yet, add the following command in your crontab settings:
Code:
cd /path/to/directory && /path/to/your_program
;
The && operator will make sure that your program isn't called unless the cd command worked properly (see man bash for details).
 
  


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
How to change the default crontab editor kawatom Red Hat 5 03-06-2011 01:07 PM
crontab doesn't work, but everything is set correctly ttilt Linux - General 10 06-16-2005 05:44 PM
howto change the editor of crontab maxut Fedora 4 08-28-2004 04:03 AM
how can I change the default editor (vipw, crontab -e) or pager? Xavius Linux - Newbie 1 04-05-2004 01:45 PM
crontab editor changes slack66 Linux - General 1 08-04-2003 08:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:50 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration