We help IT Professionals succeed at work.

how to write scheduled task in the crontab

shang3000
shang3000 asked
on
2,165 Views
Last Modified: 2008-05-02
Hi,
I have written the following  crontab file to get the code in 05.txt file executed every 5 minutes
0 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
5 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
10 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
15 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
20 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
25 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
30 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
35 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
40 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
45 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
50 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt
55 * * * * source /var/www/vhosts/20at.com/httpdocs/05.txt


the file 05.txt contains the follwing code
awk '($1 > 20){print "/etc/init.d/httpd stop;sleep 10; /etc/init.d/httpd start"}' /proc/loadavg|sh

but when I made the following command
[root@xx-xx-xx-xx httpdocs]# crontab crontab

I get the following error message:
"crontab":12: premature EOF
errors in crontab file, can't install.


please help me and guide me how to get this task done succesfully as soon as possible

Best Regards
HG
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thanks man for your help,
would you please tell me where is the log file that display that the script have been executed
CERTIFIED EXPERT
Top Expert 2006

Commented:
Generally it is preferred to have something of your own. Like you may put something in your script to log. For the default cron logs, check

/etc/default/cron
/var/cron/log
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.