Koozali.org: home of the SME Server

Crontab job error

Offline smnirosh

  • ****
  • 329
  • +0/-0
  • Learning never ends
Crontab job error
« on: March 01, 2017, 11:06:04 AM »
I have set a crontab job since last November to delete a folder that is ok to delete every odd weeks of the month.
30 8 * * 2 test $(($(date +\%W) \%2)) -eq 1 && bash.sh

bash file contains;
#!/bin/bash
mount -t cifs source destination
rm -r -R /mnt/excel/check_list
if [ "$?" -eq "0" ];
then
umount /mnt/excel/check_list
fi


But from 14 February, the code gave me following error massage and i can't figure out what happened to the code.
/bin/sh: 09: value too great for base (error token is "09")

Mysterious thing is that I didn't edit this command for nothing. I am not an expert in bash scripting.

any help

Offline smnirosh

  • ****
  • 329
  • +0/-0
  • Learning never ends
Re: Crontab job error
« Reply #1 on: March 01, 2017, 11:34:32 AM »
Sorry i made a mistake,
the error occured first time was 21 Feb.
thanks

Online Stefano

  • *
  • 10,836
  • +2/-0
Re: Crontab job error
« Reply #2 on: March 01, 2017, 11:35:24 AM »
did you try to search with google for 'sh: 09: value too great for base (error token is "09")' string?
it gaves me about 16200 results.. :-)


Offline smnirosh

  • ****
  • 329
  • +0/-0
  • Learning never ends
Re: Crontab job error
« Reply #3 on: March 01, 2017, 11:41:35 AM »
Yes i am searching for that, and change my code as thier explainations.
Because of my poor knowledge of scripting thier suggetions not work. May be i am missing something simple or something complicating, don't know. Vediamo

Online Stefano

  • *
  • 10,836
  • +2/-0
Re: Crontab job error
« Reply #4 on: March 01, 2017, 11:56:43 AM »
if you execute your script (the bash.sh) manually, does it work?

Online Stefano

  • *
  • 10,836
  • +2/-0
Re: Crontab job error
« Reply #5 on: March 01, 2017, 11:59:35 AM »
BTW, AFAICT your issue is with number formatting.. 09 is treated as an octal number, and it's wrong..

see here:
http://stackoverflow.com/questions/21049822/bash-error-value-too-great-for-base-error-token-is-09

Offline smnirosh

  • ****
  • 329
  • +0/-0
  • Learning never ends
Re: Crontab job error
« Reply #6 on: March 01, 2017, 12:18:30 PM »
thanks very much stefano. this link helped to find out the reason. I add "10" at the begining of $(, then it runs.
I've never thought a thing such like this. :( :( :(

Online Stefano

  • *
  • 10,836
  • +2/-0
Re: Crontab job error
« Reply #7 on: March 01, 2017, 12:24:19 PM »
you are welcome..

BTW, if I were in your shoes, I'd work on your script.. it's error prone, you delete file from outside the target dir (a EVIL thing to do), you mount a remote share without checking if it's already mounted... and so on.. :-)

my 2c