Setting up a cron job


Forum: Other Help Topics
Topic: Setting up a cron job
started by: Thulemanden

Posted by Thulemanden on July 15 2006,08:10
I need to run the statistics application Webalizer in command mode every hour. I know this:  0 1 * * * webalizer

I recall it is best with making a file with the command and then have this files executed on boot (by crond?), so the file runs webalize each hour.

But I recall no more the exact way.   :(  

I need to know

1) The name I have to call above file
2) where to put it
3) what to put in it
4) how to have the file executed on boot

or better :)

Hope someone has the time and effort to help me on this.

Thank you

Posted by Thulemanden on July 15 2006,10:55
I managed to install kcron and set this up. Hope it helps. :D

Which file can I now check to see the code?

Posted by mulanee on July 15 2006,17:15
Just command crontab -e
Posted by skaos on July 16 2006,12:04
If I remember correctly you have to include the full path to commands in the cron entry, i.e. 0 1 * * * /full/path/to/webalizer
Posted by Thulemanden on July 29 2006,22:30
Quote (skaos @ July 16 2006,09:04)
If I remember correctly you have to include the full path to commands in the cron entry, i.e. 0 1 * * * /full/path/to/webalizer

OK, I did that.

After installing Kcron, the command crontab does not exist, but Kcron seem to work outside of crontab. Maybe it's using cron directly?

Posted by kluber on Aug. 01 2006,07:26
I build a Cron extension : cron30.dsl
You can find them in the myDsl testing area, please try it and tell me if it achieve your tasks.

Posted by Zucca on Aug. 02 2006,06:47
I read somewhere:
Quote
00 4 * * 0 root echo "This command is run at 4 am every Sunday"
* 4 * * Sun root echo "So is this"

Doesn't that last line actually occur every minute at 4 am? Like 04:XX.
If I remember correctly, crond checks every minute if it needs to run something...

Code Sample
$ sudo crond --help
sudo: crond: command not found
$ sudo crontab --help
sudo: crontab: command not found

Ok. It seems there's no cron.

I could install it, but I'd rather write simple bash script using sleep command in it...

Posted by sankarv on Aug. 02 2006,07:13
Hi Thulemanden,
Please check the cron format u mentioned (0 1 * * * ) u said u need to run every hour.

But this format runs every day at 1'O clock.

here first parameter is minute, second is hour, third is date of month ,fourth is month, fifth is day of week.


minute (0-59)
hour (00-23)
date(1-30 or 31) (for february 28/29))
month (1-12)
day of week (0-7)

0 and 7 - sunday
1- monday
2-tuesday
3-wednesday
4-thursday
5-friday
6-saturday


If you mention * in any of the respective fields it runs all time.
the crontab file is checked each minute by cron daemon.


if u want to run every hour (XX * * * *)
where
XX-minute (0-59)



hope im right

u can edit the crontab file by


crontab -e command

-r is for remove -l is for listing the entries

you add an entry to crontab file as

00 * * * * /path/webalizer


00 * * * * nohup /path/webalizer (this will run even if you are not logged in)

Posted by Zucca on Aug. 02 2006,07:37
< There's > a good howto to cron.

Here's also a simple way to set deschules without cron:
Code Sample

#!/bin/bash

while [ "forever" -eq "forever" ]
do
 sleep 1m && source /etc/simplecron/minute.run &
done

while [ "forever" -eq "forever" ]
do
 sleep 10m && source /etc/simplecron/tenminute.run &
done

while [ "forever" -eq "forever" ]
do
 sleep 1h && source /etc/simplecron/hour.run &
done

# And so on...
# Copy freely as long you don't sue me.



I haven't tested this but it should work..?

EDIT: Oh noe! It wont work at all. =D It was just an idea... Hmmm. DO NOT TRY THIS. =D

I'll write working one later...

Posted by Zucca on Aug. 02 2006,08:36
This works.

Code Sample
#!/bin/bash

while [ "forever" == "forever" ]
do
 sleep 1m && source /etc/shcron/minute.run
done &

while [ "forever" == "forever" ]
do
 sleep 10m && source /etc/shcron/tenminute.run
done &

# Again: no copyright, no suying.
# All lawyers reserved.


Now it sources minute.run once in a minute and tenminute.run once in ten minutes.

Anyone like to enhance? Please do. =)

Posted by ^thehatsrule^ on Aug. 02 2006,19:19
just a note: I think you can just use while true
unless you like that statement :p

Posted by Zucca on Aug. 02 2006,20:15
Jeah. Never thought that. I guess I was just symboling the meaning of those loops. :D
Posted by Zucca on Aug. 03 2006,04:48
By the way...
Why there's no cron included in DSL? As far as I know cron should not take much space...

Posted by Thulemanden on Aug. 03 2006,16:11
Those loooking to 'install' crontab: install cron and this willl configure a file called crontab ;-)

Kcron or pact is a GUI to cron creating a crontab entry.

Posted by Zucca on Aug. 07 2006,13:43
Quote (Thulemanden @ Aug. 03 2006,14:11)
Those loooking to 'install' crontab: install cron and this willl configure a file called crontab ;-)

Kcron or pact is a GUI to cron creating a crontab entry.

I didn't really get that...
What's 'this'?

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.