Originally Posted by willy_gn
I am trying to have the files from /user/directory copy every hour to /backup/user/directory. It would seem that cron or crontab is what I need to use. Looking at previous posts and other documentation only shows how much I don't know. When I type crontab -e I get a blank file I can type into, seemingly using vi as the editor. I have no problem with that but when I type cron -l, i get my text after a message about "DO NOT EDIT THIS FILE.....
What I am reading just makes no sense, I am not understanding even the most fundamental aspects of cron or crontab. Any idea where I can get the most basic of basic instructions to try to understand this function?
you are correct that crontab -e is a file being edited in vi. The changes are stored in the users crontab file, which as it says, should not be edited directly (DO NOT EDIT THIS FILE DIRECTLY).
When you put something into cron it needs two things, when it should run, and what it should run.
Here is an example for what you want to do:
type crontab -e to edit your crontab file. Then insert the following:
0 * * * * cp /user/directory /backup/user/directory
save the file and the above command will run every hour.
the 0 * * * * is the time/day fields. They are as follows:
1 minute (0-59)
2 hour (0-23)
3 day of month (1-31)
4 month (1-12, or name such as jan, feb, etc)
5 day of week ( 0-6(6 = Sunday) or name such as mon, tue,etc)
6 command to run
So for your example 0 means the first minute (between the first 1 and 60 seconds).
all the * mean is every. So every hour, every day of the month, every month, every day of the week.