?
Solved

linux cron job

Posted on 2006-10-19
10
Medium Priority
?
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

743 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