Solved

linux cron job

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

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
is my large folder zipped corrupted 4 66
centos linux 65 126
ifconfig 4 46
Securing Azure Oracle instance of Linux VM 4 57
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 …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

776 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