Link to home
Start Free TrialLog in
Avatar of pavan27
pavan27Flag for United States of America

asked on

how to create crontab file and add entires in crontab.

hai exprts,

i have couple of questions.
how to create corntab file. is it DBA responsibility or SA responsibility.
how to check if crontab file is exist or not. if file is not there then how do i create. or do i need to ask SA.
can i have more than one crontab file?
how to make entry on crontab file?
how to remove entries in crontab file?
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

crontab can be created by normal users on the system as well as by SA.

The crontab is a schedule of scripts to run so it can have schedules of many scripts

the syntax is:

min hr dom mon dow command/script

The script should:

- be executable
- contains all needed env variables like HOME, PATH, etc
- commands and files should be referred to by full path names e.g. /usr/bin/ls /dir/file
- output and errors to be redirected e.g. /usr/bin/ls /dir/file > /path/to/mylog 2>&1

to create a crontab you need to:

EDITOR=vi ; export EDITOR

crontab -e

this will call for you a temp file which contains all existing job schedules (or empty file if none). Add or delete schedules from this temp file then save and exit. The temp file will be edited using vi commands

you may add schedules like

0 12 * * * /path/to/myscript

for more info please see

man crontab
man cron

Avatar of pavan27

ASKER

i am getting this error.

VMPPRD:cavecreek:{oracle}70% crontab -l
crontab: can't open your crontab file.

what could be the reason
it could be that you don't have any schedule so far. create one then try again
Avatar of pavan27

ASKER

{oracle}75% export EDITOR=vi
export: Command not found.

:{oracle}75% EDITOR=vi ; export EDITOR
EDITOR=vi: Command not found.
export: Command not found.

i am not able to set editor too
ASKER CERTIFIED SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pavan27

ASKER

:{oracle}82% echo $SHELL
/bin/sh
did you try

EDITOR=vi ; export EDITOR

any way you can do it other way:

vi mycron

add to it the schedule e.g.

0 12 * * * /path/to/myscript

save and exit

run

crontab mycron
crontab -l