Solved

linux cron job

Posted on 2006-10-19
10
327 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now