How do I setup a cron job?

andel

Regular Member
Joined
Jun 16, 2009
Messages
275
Reaction score
0
Points
16
Age
49
My Satellite Setup
DM800, DM600, Technomate Diseqc Motor, 90cm Dish
Panasonic 42" Plasma 1080p
Pioneer VSX-LX70 Amp
Sky HD
B & W 5.1 Speaker Setup
Popcornhour Media center
Xbox 360
My Location
Watching T.V in the UK
Ok, so I have a script to check that CCcam is running. the script works without a problem.
I'm running Darkstar II and want to setup a cron job to run the script every minute .
I've telnet to the box and typed 'crontab -e' and it seems to create a crontab in /var/spool/cron/. I added * * * * * /bin/CCcamcheck.sh/ to the crontab but now im stuck.
Can anyone help me?
 

compufunk

Regular Member
Joined
May 7, 2008
Messages
1,658
Reaction score
1
Points
38
My Satellite Setup
DM 600-S, VU+ Duo,
Moteck SG2100, Fracarro Penta 85 dish, LG LH3000 42" TV + some computers
My Location
NW, Ireland
Are you sure the cron daemon is running? If not, start it with 'crond'.

Also, you shouldn't have a trailing forward slash at the end of your command. It should read.....
Code:
* * * * * /bin/CCcamcheck.sh
The the forward slash is telling the system to look for a directory called CCcamcheck.sh, which I presume it is not.
 

andel

Regular Member
Joined
Jun 16, 2009
Messages
275
Reaction score
0
Points
16
Age
49
My Satellite Setup
DM800, DM600, Technomate Diseqc Motor, 90cm Dish
Panasonic 42" Plasma 1080p
Pioneer VSX-LX70 Amp
Sky HD
B & W 5.1 Speaker Setup
Popcornhour Media center
Xbox 360
My Location
Watching T.V in the UK
you're right, i shouldnt have that trailing /
So do i just type crond to start? or do i need a path to the crontab too? (sorry this is all new to me)
 

compufunk

Regular Member
Joined
May 7, 2008
Messages
1,658
Reaction score
1
Points
38
My Satellite Setup
DM 600-S, VU+ Duo,
Moteck SG2100, Fracarro Penta 85 dish, LG LH3000 42" TV + some computers
My Location
NW, Ireland
Yes, just type 'crond' and hit enter to start the cron daemon.

I notice you are using /var/spool/cron/ whereas I created my jobs in /var/spool/cron/crontabs.

With Darkstar II on a DM600 the following was how I did it. (Not sure what box your using).

When I was setting it up initially, i had to create a directory for my cron jobs.

To create the directory, do the following in a telnet/ssh terminal.
Code:
mkdir -p /var/spool/cron/crontabs/

Then create the cron job as follows.....
Code:
 echo "* * * * * /bin/CCcamcheck.sh" >> /var/spool/cron/crontabs/root
Rather than type it all out, you can copy the above command into your terminal by right clicking on screen and pasting.

Check that its all OK as follows........
Code:
more /var/spool/cron/crontabs/root
This should output the following text to screen.
Code:
* * * * * /bin/CCcamcheck.sh

Provided you've started the cron daemon that should be it.
 

andel

Regular Member
Joined
Jun 16, 2009
Messages
275
Reaction score
0
Points
16
Age
49
My Satellite Setup
DM800, DM600, Technomate Diseqc Motor, 90cm Dish
Panasonic 42" Plasma 1080p
Pioneer VSX-LX70 Amp
Sky HD
B & W 5.1 Speaker Setup
Popcornhour Media center
Xbox 360
My Location
Watching T.V in the UK
Thats exactly what i was looking for, thanks, just one more thing. I assume when i reboot my box i will have to send the 'crond' command. How do I set it up so 'crond ' starts on boot?
 

compufunk

Regular Member
Joined
May 7, 2008
Messages
1,658
Reaction score
1
Points
38
My Satellite Setup
DM 600-S, VU+ Duo,
Moteck SG2100, Fracarro Penta 85 dish, LG LH3000 42" TV + some computers
My Location
NW, Ireland
I'm not sure that it will when you activate it via command line.

It will start at boot time if you activate it with your remote control via the Services/Daemons window.

Im using Gemini at the minute so cant tell you where that option is on Darkstar II.

On Gemini its under Blue Panel -> Services/Daemons -> Crond.

Have a look under Blue Button -> Extra Settings. It might be there.
 

andel

Regular Member
Joined
Jun 16, 2009
Messages
275
Reaction score
0
Points
16
Age
49
My Satellite Setup
DM800, DM600, Technomate Diseqc Motor, 90cm Dish
Panasonic 42" Plasma 1080p
Pioneer VSX-LX70 Amp
Sky HD
B & W 5.1 Speaker Setup
Popcornhour Media center
Xbox 360
My Location
Watching T.V in the UK
I find that when i reboot, the folders and the cron job I have created disappear! Any suggestions as to why this is happening?
 

compufunk

Regular Member
Joined
May 7, 2008
Messages
1,658
Reaction score
1
Points
38
My Satellite Setup
DM 600-S, VU+ Duo,
Moteck SG2100, Fracarro Penta 85 dish, LG LH3000 42" TV + some computers
My Location
NW, Ireland
Sorry, I meant to get back to you sooner on this, but forgot about it. :-doh2

It seems that at least part if not all of the /var directory is being dynamically created at boot time. The following command is run during boot, which extracts the contents of /etc/var.tar.gz to /var.
Code:
tar xzf /etc/var.tar.gz -C /

To get around this, I've made a little script to create the cron job during boot. This is far from an elegant solution, but at least it works. I'm sure there is a better way, I just haven't got physical access to a Darkstar II box at the minute to check it out.

Rename the attached file so that the .txt extension is removed, then FTP it to /usr/bin/ and make sure its executable by running chmod on it.
Code:
chmod 755 /usr/bin/create_cron.sh

To get this script to run at boot time, execute the following command.
Code:
echo "/usr/bin/create_cron.sh" >> /etc/init.d/bootup
Copy and paste this command into your preferred telnet terminal. A mistake in typing it could lead to having to reflash the box. :p

When you reboot, the cron job should be created and activated. I've tested this remotely on a DM600 running Darkstar II.
 

Attachments

  • create_cron.sh.txt
    272 bytes · Views: 284

andel

Regular Member
Joined
Jun 16, 2009
Messages
275
Reaction score
0
Points
16
Age
49
My Satellite Setup
DM800, DM600, Technomate Diseqc Motor, 90cm Dish
Panasonic 42" Plasma 1080p
Pioneer VSX-LX70 Amp
Sky HD
B & W 5.1 Speaker Setup
Popcornhour Media center
Xbox 360
My Location
Watching T.V in the UK
Hey compufunk I didn't see your reply there, thanks a lot anyway.
Just one more question.
If I want to add another cron job to schedule a reboot of the box at 4am everyday, can I add another line in the create_cron.sh?
Would it be something like?
Code:
echo "* 04 * * * reboot" >> /var/spool/cron/crontabs/root
 

compufunk

Regular Member
Joined
May 7, 2008
Messages
1,658
Reaction score
1
Points
38
My Satellite Setup
DM 600-S, VU+ Duo,
Moteck SG2100, Fracarro Penta 85 dish, LG LH3000 42" TV + some computers
My Location
NW, Ireland
That should do it I think.
 
Top