Koozali.org: home of the SME Server
Obsolete Releases => SME 7.x Contribs => Topic started by: JoshuaR 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:
# refresh access list
*/5 * * * * root /path/to/script.sh
as a test, I run expand-template /etc/crontab
which if I then 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
-
check cron's log
I bet a beer the problem is in your script ;-) (hint: paths and environment variables)
-
check cron's log
ahh, sometimes the most obvious things slip past :P
I'm getting:
May 13 00:00:01 hostname crond[7647]: (root) CMD (/path/to/script.sh^M)
I'm not sure where it's pulling the ^M
from
-
ahh, sometimes the most obvious things slip past :P
I'm getting:
May 13 00:00:01 hostname crond[7647]: (root) CMD (/path/to/script.sh^M)
I'm not sure where it's pulling the ^M
from
My guess it is in your template fragment somewhere. Did you check that already?
-
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
-
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.
-
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
-
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 )
-
use your favourite editor in SME's console ;-)
-
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
-
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 :!:
-
^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
-
Cheers, that's worked.
--Josh R
-
Cheers, that's worked.
--Josh R
I forgot: I've lost my bet.. you have a virtual beer payed ;-)
-
:pint:
cheers