Koozali.org: home of the SME Server

crontab entry help

Offline JoshuaR

  • ****
  • 125
  • +0/-0
    • Tech-Eze
crontab entry help
« on: May 12, 2010, 03:51:40 PM »
Hi,
I am working on my first SME contrib (slowly  :P) and part of it involves creating a cron job. It does so by creating a file called 20mycontrib in /etc/e-smith/templates/etc/crontab/
the content of the file is:
Code: [Select]
# refresh access list
*/5 * * * * root /path/to/script.sh
as a test, I run
Code: [Select]
expand-template /etc/crontab which if I then
Code: [Select]
cat /etc/crontab I can see my entry formatted correctly etc, but for some reason it just doesn't run. I think my cron sytax is right (above should run every 5 min?) and if I manually run the script it runs fine.
Can anyone point out where I'm going wrong?

--Josh R
« Last Edit: May 12, 2010, 03:59:47 PM by JoshuaR »
Life's tragedy is that we get old too soon, and wise too late...

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: crontab entry help
« Reply #1 on: May 12, 2010, 04:02:28 PM »
check cron's log

I bet a beer the problem is in your script ;-) (hint: paths and environment variables)

Offline JoshuaR

  • ****
  • 125
  • +0/-0
    • Tech-Eze
Re: crontab entry help
« Reply #2 on: May 12, 2010, 04:06:55 PM »
Quote
check cron's log
ahh, sometimes the most obvious things slip past :P
I'm getting:
Code: [Select]
May 13 00:00:01 hostname crond[7647]: (root) CMD (/path/to/script.sh^M)
I'm not sure where it's pulling the
Code: [Select]
^M from
Life's tragedy is that we get old too soon, and wise too late...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: crontab entry help
« Reply #3 on: May 12, 2010, 04:11:42 PM »
ahh, sometimes the most obvious things slip past :P
I'm getting:
Code: [Select]
May 13 00:00:01 hostname crond[7647]: (root) CMD (/path/to/script.sh^M)
I'm not sure where it's pulling the
Code: [Select]
^M from
My guess it is in your template fragment somewhere. Did you check that already?
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline JoshuaR

  • ****
  • 125
  • +0/-0
    • Tech-Eze
Re: crontab entry help
« Reply #4 on: May 12, 2010, 04:15:16 PM »
Thanks heaps! That was it, in my template fragment I had two line 'line breaks' after the cron entry.
I had checked it, I just didn't realize that it would cause a problem.

Cheers,
Josh R
Life's tragedy is that we get old too soon, and wise too late...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: crontab entry help
« Reply #5 on: May 12, 2010, 04:19:41 PM »
Thanks heaps! That was it, in my template fragment I had two line 'line breaks' after the cron entry.
I had checked it, I just didn't realize that it would cause a problem.
Most likely it has nothing to do with a two line line break. My guess is that one of them was a special non printable character.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: crontab entry help
« Reply #6 on: May 12, 2010, 04:21:15 PM »
Most likely it has nothing to do with a two line line break. My guess is that one of them was a special non printable character.

me too

Offline JoshuaR

  • ****
  • 125
  • +0/-0
    • Tech-Eze
Re: crontab entry help
« Reply #7 on: May 12, 2010, 04:23:00 PM »
I've been using Notepad++ as my editor...I wonder if that maybe did it? In viewing the file the two extra lines didn't seem to contain anything.

Edit: When I removed the extra line I used vi   as soon as I edited the file with Notepad++ and applied it again, it appended that ^M  .
Thanks guys.

(on that note, can you recommend a good editor--I'm worried about the integrity of the rest of my contrib now :P )
« Last Edit: May 12, 2010, 04:28:33 PM by JoshuaR »
Life's tragedy is that we get old too soon, and wise too late...

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: crontab entry help
« Reply #8 on: May 12, 2010, 04:44:07 PM »
use your favourite editor in SME's console ;-)

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: crontab entry help
« Reply #9 on: May 12, 2010, 05:58:44 PM »
I've been using Notepad++ as my editor...I wonder if that maybe did it? In viewing the file the two extra lines didn't seem to contain anything.

Edit: When I removed the extra line I used vi   as soon as I edited the file with Notepad++ and applied it again, it appended that ^M  .
Thanks guys.

(on that note, can you recommend a good editor--I'm worried about the integrity of the rest of my contrib now :P )
AFAIK Notepad++ is a good, but extensive editor. It might be that you do not have the document format set properly. Under encoding you set the encoding type, not sure what it should be for SME Server though.

But as others said there are plenty of editors on your SME Server/linux box that will do the trick as well. :-D
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline JoshuaR

  • ****
  • 125
  • +0/-0
    • Tech-Eze
Re: crontab entry help
« Reply #10 on: May 12, 2010, 06:56:41 PM »
I still find it quicker to navigate an editor with a (dare I say 'GUI' in a linux forum?)  :grin:
Thanks for the advice guys  :!:
Life's tragedy is that we get old too soon, and wise too late...

Offline timn

  • *
  • 62
  • +0/-0
    • Nash CDL
Re: crontab entry help
« Reply #11 on: May 12, 2010, 08:03:32 PM »
^M is a carriage return so probably saved the file in MSDOS/Windows format with a CR/LF pair to start new lines

Goto View -> Show Symbol -> Show End of Line (or Show All Symbols) to see what is being saved.

Also use Edit -> EOL Conversion -> Unix Format to save with just LF at the end

Offline JoshuaR

  • ****
  • 125
  • +0/-0
    • Tech-Eze
Re: crontab entry help
« Reply #12 on: May 12, 2010, 11:56:39 PM »
Cheers, that's worked.

--Josh R
Life's tragedy is that we get old too soon, and wise too late...

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: crontab entry help
« Reply #13 on: May 13, 2010, 12:20:49 AM »
Cheers, that's worked.

--Josh R

I forgot: I've lost my bet.. you have a virtual beer payed ;-)

Offline JoshuaR

  • ****
  • 125
  • +0/-0
    • Tech-Eze
Re: crontab entry help
« Reply #14 on: May 13, 2010, 02:27:05 AM »
 :pint:
cheers
Life's tragedy is that we get old too soon, and wise too late...