Databases Reference
In-Depth Information
Setting Default Editor
The default editor invoked to modify the cron table is dependent on the value of your VISUAL OS variable. In my
current environment the VISUAL variable is set to vi :
$ echo $VISUAL
vi
If the VISUAL OS variable isn't set, then the value of EDITOR is used to define the default editor. Make sure that
either VISUAL or EDITOR is set to your editor of choice. If neither VISUAL nor EDITOR is set, your system will default to
the ed editor. In this scenario, you'll be presented with the following prompt:
26
<blank prompt>
Press the Q key to exit from ed . You can have the VISUAL or EDITOR variable automatically set for you when you
log in to the system. You can also manually set the editor with the export command. The following example sets the
default editor to vi :
$ export EDITOR=vi
Consider putting the prior line of code in a startup file (such as .bashrc ) so that your editor is set consistently.
Loading the cron Table from a File
The other way to modify your cron table is to load it directly with a file name, using the following syntax:
$ crontab <filename>
Here, the crontab utility will load the contents of the specified file into your cron table. The recommended steps
to modify your cron table with this method are as follows:
Before modifying your cron table, first populate a file with the cron table's current
contents; for example,
1.
$ crontab -l > mycron.txt
Next, make a copy of the previously created file ( mycron.txt ). This allows you to revert
back to the original file, in the event that you introduce errors and can't readily figure out
what's incorrect. This also provides you with an audit trail of changes to your cron table:
2.
$ cp mycron.txt mycron.jul29.txt
Now, edit the mycron.txt file with your favorite text editor:
3.
$ vi mycron.txt
For example, to schedule a script named backup.bsh to run daily, at 11:05 pm, add the following lines:
#---------------------------------------------------------------------------------
# File backup, dk: 20-jan-14, inserted.
5 23 * * * /home/oracle/bin/backup.bsh
#---------------------------------------------------------------------------------
 
Search WWH ::




Custom Search