At the end of every year, I need to create some new directories to hold
log files with the directory name reflecting the new year on a
CentOS
Linux system. To create those directories on the last day of the year,
December 31, I can use the cron utility found on Linux/Unix and OS X/MacOS systems
to schedule a cronjob to run on the last day of the year. I can edit the
crontab file
that holds jobs to be run at a scheduled time or times by issuing the
crontab command
crontab -e
, which will allow me to edit the file with the
vi editor.
If the vi editor is the default editor, which it likely is, but you
are unfamiliar with that editor, you can change the editor for the current
login session to the GNU nano text editor, which may be easier to use for
someone unfamiliar with the vi text editor, by issuing the following command at
the command line.
export EDITOR="/usr/bin/nano"
The value will be reset when you log off or you can reset it manually with the command below:
export EDITOR="/usr/bin/vi"
I can put the following line in the crontab file to run my script named
end-of-year-dirs
at 7:00 AM on December 31 of every year. When
you add a new entry, be sure to hit the Enter key at the end of the
line.
0 7 31 DEC * /home/jdoe/scripts/end-of-year-dirs
[ More Info ]