PDA

Bekijk de volledige versie : Cron almost working but not quite...



n00ben
08-01-2007, 17:38
I've installed and set up Cron.

I've set edited crontabs to append uptime to a file each 5 min.

if I run 'logread' I get (among many other things) :
"jan 8 18:25:01 cron[1259]: (root) CMD (uptime >> /opt/etc/crontest.txt)"

my crontabs look like this:

SHELL=/opt/bin/bash
PATH:/sbin:/bin:/usr/sbin:/usr/bin:/opt/sbin/:/opt/usr/bin:/opt/usr/sbin
MAILTO=""
HOME=/
#-----------
*/5 * * * * root uptime >> /opt/etc/crontest.txt


but crontest.txt is empty and nothing is ever written to the file...

/regards
Henrik

kfurge
08-01-2007, 18:11
The first thing that comes to mind is that you need to set the LD_LIBRARY_PATH to point to /apps/lib since according to your path you'll be running the Asus stock uptime within the optware environment as root.

Second thing, your filenames are inconsistent (crontest.txt vs crontabs.txt). I'm assuming this was a typo.

- K.C.

n00ben
08-01-2007, 18:34
I added /apps/lib to LD_LIBRARY_PATH in my '.profile' and yes crontest.txt/crontabs.txt was a typo.

still no luck though. I can manually type the command and it works, and according to logread the command is performed, still no content in crontest.txt though.

I've set crontest.txt permissions to 777

EDIT: SOLVED... I just needed to set the full path to 'uptime'... doh

/regards
Henrik

kfurge
09-01-2007, 00:18
Perhaps the ":" in place of the "=" in your path was the root cause?

- K.C.

n00ben
09-01-2007, 06:31
Perhaps the ":" in place of the "=" in your path was the root cause?

nope, that was also a typo ;) (can't copy paste with my current crappy client)

I had to type the full path to 'uptime' (/opt/bin/uptime), since I forgot to add it to PATH

/regards
Henrik

sollie
09-01-2007, 16:33
Usage example:

1: Install cron
"ipkg install cron"

2: Install text editor
"ipkg install nano"

3: Edit crontab file
"nano /opt/etc/crontab

4: Change crontab to something like this.
This will overwrite /tmp/passwd every minute with a costum passwd file.

SHELL=/opt/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/sbin/:/opt/usr/bin:/opt/usr/sbin
MAILTO="" HOME=/
# ---------- ---------- Default is Empty ---------- ---------- #
*/1 * * * * root cp /shares/MYVOLUME1/MYSHARE1/run/passwd /tmp

5: Install crontab file
"crontab /opt/etc/crontab"

6: Add cron to rc.local
"cron"

7: Reboot router
"reboot"

8: You can check a log to verify crontab.
"logread"

Greetings Sollie.