MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
February
Sun Mon Tue Wed Thu Fri Sat
       
4
     
2018
Months
Feb
Nov Dec


Sun, Feb 04, 2018 11:03 pm

Run a cronjob at the end of every year

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 ]

[/os/unix/commands] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo