Solved

linux cron job

Posted on 2006-10-19
10
334 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 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