DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2007-12-10 21:09:37

pezzi
Member
Registered: 2007-10-21
Posts: 5

Problem with Script in crontab with CH3SNAS/DNS323

Hi,

i am using following crontab (root) with my box:

SHELL=/bin/sh
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
59 1 * * * /usr/sbin/daylight &
*/10 * * * * /usr/sbin/getdhcp&
5 2 * * * /mnt/HD_a2/home/user1/bin/user1-backup.sh  <--- This Entry !
5 3,7,11,15,19,23 * * * /mnt/HD_a2/fun_plug.d/start/timezone.sh 2>&1 >> /mnt/HD_a2/home/user1/.heimnas/log/timezone-log

I am having problems with the user1-backup.sh
/****************************************************************
#! /bin/sh

/bin/echo `date` Start >> /mnt/HD_a2/home/user1/.heimnas/log/rsync-log

cd /mnt/HD_a2/home/backup && /mnt/HD_a2/fun_plug.d/bin/rsync -arvul -e "ssh -p 221 -i /mnt/HD_a2/home/user1/.ssh/dbkey.rsa" --delete user1@webserver.com:"/home/user1/" . 2>&1 >> /mnt/HD_a2/home/user1/.heimnas/log/rsync-log

/bin/echo `date` Ende >> /mnt/HD_a2/home/user1/.heimnas/log/rsync-log
******************************************************************/

If i am running this bash-script with the user root from bash everything is running fine. When the script is run by cron (root) i can see the "date"-Info (Start & Ende) in the log, but the "cd /mnt ... && ..." is not executed. Anybody any hints?


Thanks

pezzi

Last edited by pezzi (2007-12-10 21:10:03)

Offline

 

#2 2007-12-10 21:59:58

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Problem with Script in crontab with CH3SNAS/DNS323

Environment is probably missing a few variables (like PATH, LD_LIBRARY_PATH, ...). If there's a /mnt/HD_a2/fun_plug.d/etc/profile file, include it in your script:

Code:

#!/bin/sh

. /mnt/HD_a2/fun_plug.d/etc/profile

/bin/echo ...

PS: It's not a 'bash' script, but shell script.
PPS: You can catch error messages by adding >/.../log 2>&1 to the crontab line.

Offline

 

#3 2007-12-15 23:05:54

pezzi
Member
Registered: 2007-10-21
Posts: 5

Re: Problem with Script in crontab with CH3SNAS/DNS323

That's it. Thank you.

Offline

 

#4 2008-04-14 20:45:42

andrey
Member
Registered: 2008-03-22
Posts: 34

Re: Problem with Script in crontab with CH3SNAS/DNS323

fonz / penny,

I seem to run into a very similar problem with my script, but it looks like the suggestion to add profile link doesn't seem to work. I'm using fun_plug 04 and here are my scripts:

# crontab
32 2 * * * /usr/sbin/rtc -s
30 2 2 * * /usr/sbin/rtc -c
59 1 * * * /usr/sbin/daylight &
00 1,2,3,4,5 * * * sh /mnt/HD_a2/radio/Radio.sh &
05 6 * * * sh /mnt/HD_a2/radio/update-clean.sh >/mnt/HD_a2/radio/update-clean.sh/update_clean.log 2>&1

and update-clean.sh

#!/bin/sh

. /mnt/HD_a2/fun_plug.d/etc/profile

FOLDER=/mnt/HD_a2/data/Music/Radio-Streams\/`date '+%m-%d-%Y'`\/
FOLDER_TMP=/mnt/HD_a2/data/Music/Streamripper_rips

#cd $FOLDER
for i in `ls $FOLDER`
do
  FILESIZE=`ls -l $FOLDER$i|awk '{print $5}'`
  if [ $FILESIZE -lt 15000000 ]
  then
    /bin/rm $FOLDER$i
  fi
done

/bin/rm -rf $FOLDER_TMP

update_clean removes files that are less than 15 Mb after 5 hours of recording. The script, of course, works when I run it manually, but it doesn't work from the crontab. I'm not even sure after trying the above suggestion on what might be causing the failure. Any thoughts?

Last edited by andrey (2008-04-14 20:46:50)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB