Welcome to WebmasterWorld Guest from 54.147.63.124

Forum Moderators: bakedjake

Message Too Old, No Replies

Edit crontab.vim file

How do i run program through crontab.vim file

     
7:04 pm on Sep 27, 2007 (gmt 0)

New User

5+ Year Member

joined:Sept 20, 2006
posts:7
votes: 0


Hi All,

I am having a problem to run a program through crontab.vim file which is located in this directory:/usr/share/vim/vim71/syntax/crontab.vim. When i run a shell script program by putting my file . It does not run.

Any help will be appreciated..

Thanks

8:04 pm on Sept 27, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jtara is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 26, 2005
posts:3041
votes: 0


I'm not sure what you are asking.

crontab.vim isn't used to "run a program". It's a file which comes with the vim editor. It tells vim how to parse crontab files, so that it can display them with neat colors.

There's probably nothing that you should be doing with crontab.vim, except leaving it alone.

10:43 pm on Sept 27, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 11, 2003
posts:5063
votes: 11


On my system, if you enter:
crontab -l
it lists all the cron jobs. To add a new cron job or edit the existing ones I would enter this:
crontab -e
Which will open an editor. You don't put the programs themselves in there, just the one line per script that points at the script and tells it when to run. So I would see a file like this:
0 3 * * * /path/to/my/script
which would run that script at 3 in the morning every night. Of course I have to make sure that executing
/path/to/my/script
actually works directly from the command line.

In other words, you edit the crontab using the crontab -e command, but that's just the list of individual programs to run using cron. And don't edit it using vim, use crontab -e.

HTH.

4:27 pm on Sept 28, 2007 (gmt 0)

New User

5+ Year Member

joined:Sept 20, 2006
posts:7
votes: 0


Can you please tell me how can I run cron jobs using vim editor? I am using cygwin and vim editor.

Thanks

5:40 pm on Sept 30, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 11, 2003
posts:5063
votes: 11


You don't 'run cron jobs through vim'.

First you create a script. That script could be writtin in PHP, or Java, or a shell script, or in whatever. You can run this script from the command line. THis step has nothing to do with vim or cron. You just need a program of some type that already can be run on your server.

You then use a command like 'crontab -e' which will launch vim to edit the crontab file. You edit this file to tell it what time and dates to run the above script.

You don't use crontab to create or edit scripts. You only use cron to run scripts that already exists, at specific times.

5:16 pm on Nov 4, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:July 28, 2003
posts:188
votes: 0


Bob,

Your question is a little confusing, but what you MAY be looking for is that your need to make sure your EDITOR environment variable is set to the editor you want to use while editing your crontab file. The exact syntax varies with what shell you are using, but one of the following two will likely work:

(sh style) Bash, ksh:
EDITOR=vim ; export EDITOR

(csh style):
setenv EDITOR vim

That is assuming that the command you type to use vim is in fact 'vim'. If it's actually vi, then set it to 'vi' instead.

After that, typing crontab -e will use vim to edit your crontab. To make the change in your EDITOR environment variable permanent, you'll need to change your startup .profile or .cshrc to include the command.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members