Solved

linux cron job

Posted on 2006-10-19
10
333 Views
Last Modified: 2010-04-20
hello,
I have logged in as root into my Centos v4.3 server and did 'crontab -e' then added this two lines

0 0 * * * cp /dev/null /home/virtual/domain1.net/var/log/httpd/error.log
0 1 * * * cp /dev/null /home/virtual/domain2.com/var/log/httpd/error.log

then saved the file, how can I run those two lines every hour ?
0
Comment
Question by:Sabrin
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17769275
0 * * * * cp /dev/null /home/virtual/domain1.net/var/log/httpd/error.log
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 17769640
Hi,

0 * * * * > /home/virtual/domain1.net/var/log/httpd/error.log

will do too :)
0
 
LVL 14

Expert Comment

by:ygoutham
ID: 17771601
hi in the crontab -e option

these are the options of first five fields

min
hour
date in month (1 to 31)
month
weekday

for more options you can always do a "man 5 crontab" which gives examples and other options as to how to do it.

goutham
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:Sabrin
ID: 17773992
I want every hour for the 3 domains in each one after 5 minutes

1 hours
0 0 * * * cp /dev/null /home/virtual/domain1.net/var/log/httpd/error.log

1 hours after 5 minutes of 1st
0 1 * * * cp /dev/null /home/virtual/domain2.com/var/log/httpd/error.log

1 hours after 5 minutes of 2nd
0 0 * * * cp /dev/null /home/virtual/domain3.net/var/log/httpd/error.log

like that!!
0
 

Author Comment

by:Sabrin
ID: 17773995
not all at the same time
0
 
LVL 30

Accepted Solution

by:
Kerem ERSOY earned 500 total points
ID: 17774063
0 * * * * cp /dev/null /home/virtual/domain1.net/var/log/httpd/error.log
5 * * * * cp /dev/null /home/virtual/domain2.com/var/log/httpd/error.log
10 * * * * cp /dev/null /home/virtual/domain3.net/var/log/httpd/error.log

This will run domain1.net at every hour , 0 minute
domain2.net every hour 5 minute
domain3 very hour 10 minute
ISn't it what you want ?
0
 

Author Comment

by:Sabrin
ID: 17774104
thanks
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 17774130
Yr welcome
0
 
LVL 3

Expert Comment

by:dbacalja
ID: 17774218
Hi,
this will clear domain1 on every full hour (1:00, 2:00 etc.), domain2 every hour + 5 minutes (1:05, 2:05 etc.) and domain3 on every full hour + 10 minutes (1:10, 2:10 etc.):

0 * * * * cat /dev/null > /home/virtual/domain1.net/var/log/httpd/error.log
5 * * * * cat /dev/null > /home/virtual/domain2.com/var/log/httpd/error.log
10 * * * * cat /dev/null > /home/virtual/domain3.net/var/log/httpd/error.log
0
 
LVL 3

Expert Comment

by:dbacalja
ID: 17774239
Ooops, seems I kept my comment window open too long! 8-))
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question