You are not logged in.

#1 2010-06-28 21:24:15

Ben9250
Member
From: Bath - England
Registered: 2010-06-10
Posts: 208
Website

[SOLVED] Which Method of using Cron

Hiya all, I've been setting some alias's and things to help with backing up and updating my system and I'd like to use cron to get some of them working automatically. There are two ways I see of doing this, currently I have no crontab files for my user (crontab -l says so and I've got nothin'  in my cron.d folder). Anywho the root crontab has a section for cronjobs with the <minute> <hour> <day_of_month> <month> <day_of_week> <command> format and a way to point to daily weekly monthly system folders. And I had a look at these folders and they contain different scripts. So which would be the best way (new to .sh script stuff and only just read about cron)? One of the thing's I've wanted to use is Archup to show me when updates are available as a little pop-up. The instructions only show how to plonk a script in the hourly folder and then it will work. But I wanted it to run daily instead. I tried putting the .sh in the daily folder but so far it hasn't seemed to work (it does work if I type in archup at the terminal so I know theres no problem with the program). Could anyone tell me if moving the script like that is correct of if it's something else entirely? (I thought of using the  <minute> <hour> <day_of_month> <month> <day_of_week> <command> method with my aliases as the commands, but the script thing has my attention (learning opportunity big_smile))

Cheers

Last edited by Ben9250 (2010-07-05 21:41:40)


"In England we have come to rely upon a comfortable time-lag of fifty years or a century intervening between the perception that something ought to be done and a serious attempt to do it."
  - H. G. Wells

Offline

#2 2010-06-28 22:24:20

mcsilva
Member
From: Portugal
Registered: 2009-12-16
Posts: 95

Re: [SOLVED] Which Method of using Cron

The script you put in the /etc/cron.hourly must work.
Check if your script is executable (chmod +x).
Is the script written in bash? Then check if the first line is #!/bin/bash.
Instead, if you use "crontab -e",  then you can add other lines calling another script like:
0 23 * * * /root/testscript.sh

This example runs a script called /root/testscript.sh at 23h00 every day (don't forget complete path)

If you use the "directory" method you don't have to worry about the moment when it runs. Only if it is daily, weekly, hourly or monthly.
If you use "crontab -e", you can better tune the moment when the script runs.

Check /var/log/crond.log and see at what time did cron run.

Offline

#3 2010-06-28 22:52:26

Ben9250
Member
From: Bath - England
Registered: 2010-06-10
Posts: 208
Website

Re: [SOLVED] Which Method of using Cron

Hi mcsilva, thank you for replying. I've read through everything again and I was not 100% sure (more like 50:50) that O had run the line $ sudo chmod 755 /etc/cron.hourly/archup.sh mentioned in the configuration guide, which I changed to sudo chmod 755 /etc/cron.daily/archup.sh to suit where I have my .sh. I've done this and shall wait for tomorro to see if it will do as it should. I'm not sure of what this chmod command is all about. I read the stump on the wiki but that really left more questions than I had in the first place about the command, using terms like permissions in an octal notation.


"In England we have come to rely upon a comfortable time-lag of fifty years or a century intervening between the perception that something ought to be done and a serious attempt to do it."
  - H. G. Wells

Offline

Board footer

Powered by FluxBB