LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-19-2011, 10:33 AM   #1
willy_gn
LQ Newbie
 
Registered: Jun 2010
Posts: 9

Rep: Reputation: Disabled
trying to make sense of cron / crontab


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?

thank you
 
Old 03-19-2011, 10:40 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
You use
Code:
crontab -e
to create a crontab.
Code:
crontab -l
will list the crontabs on your system.
Look at
http://adminschoice.com/crontab-quick-reference
for some pointers.

Kind regards
 
Old 03-19-2011, 10:41 AM   #3
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
The answers most simple questions are available via Google search. In this case, search for "crontab tutorial", and select the one that is at a level you are comfortable with.
 
Old 03-19-2011, 10:53 AM   #4
willy_gn
LQ Newbie
 
Registered: Jun 2010
Posts: 9

Original Poster
Rep: Reputation: Disabled
thank you for your quick replies, I will keep looking
 
Old 03-19-2011, 11:13 AM   #5
savona
Member
 
Registered: Mar 2011
Location: Bellmawr, NJ
Distribution: Red Hat / Fedora
Posts: 195

Rep: Reputation: 50
Quote:
Originally Posted by willy_gn View Post
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?

thank you

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.

Last edited by savona; 03-19-2011 at 11:15 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/crontab vs /etc/cron.d vs /var/spool/cron/crontabs/ drManhattan Linux - Newbie 9 01-04-2011 02:12 AM
how to make the cron file take effect[crontab] edenCC Linux - Software 3 08-11-2007 01:05 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 02:57 AM
This just doesn't make any sense! FreezEy Debian 8 04-18-2006 09:35 PM
How does this make sense? Trinity22 Linux - General 2 03-30-2005 01:45 AM


All times are GMT -5. The time now is 10:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration