LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   script output different when cron runs it (https://www.linuxquestions.org/questions/linux-general-1/script-output-different-when-cron-runs-it-4175546688/)

aristosv 06-28-2015 11:27 PM

script output different when cron runs it
 
When I manually run the script below, the output is just the way I want it. When cron runs it, I get like fifty of these ::::::::: in the output of the script.

Is there any chance cron is doing something different when running the script? Any way I can get additional information that will help me troubleshoot the issue?

crontab -e
Code:

@daily /root/daily
/root/daily
Code:

#!/bin/bash
#Import Variables
source /root/config/variables
#Random Delay
/bin/sleep $((RANDOM$delayreboot))
#Run Daily
/root/start


Keruskerfuerst 06-29-2015 12:03 AM

Which distro and which version of cron?

aristosv 06-29-2015 12:14 AM

I'm running raspbian, but I couldn't find a way to get the cron version..

cat /etc/*-release
Code:

PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
NAME="Raspbian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=raspbian
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"


Keruskerfuerst 06-29-2015 12:18 AM

cron --version?

aristosv 06-29-2015 12:20 AM

No, not working. I've also googled it and tried to find other ways but nothing works. Cron is running though that's for sure.

cron --version
Code:

cron: invalid option -- '-'
usage: cron


Keruskerfuerst 06-29-2015 01:52 AM

Which image?

aristosv 06-29-2015 02:35 AM

I am using the image that was released on 2015-02-16
Its the previous one from the current.

suicidaleggroll 06-29-2015 10:05 AM

It's difficult to say since you haven't showed us what's in /root/config/variables or /root/start.

And what script output are you referring to? You don't have anything going to a log file in what you've shown.

Habitual 06-29-2015 07:37 PM

n/m. Sorry.
<vacant_stare>

aristosv 06-29-2015 10:29 PM

start
Code:

#!/bin/bash
/root/config/commands 2>&1 > /root/log/$HOSTNAME.log

commands
Code:

#!/bin/bash
#Set Variables
source /root/config/variables
#Download Media
/bin/echo "Sync $(/usr/bin/lftp ftp://$ftpuser:$ftppass@$ftphost -e "set ftp:ssl-allow no ; set net:reconnect-interval-base 5 ; set net:max-retries 2 ; mirror -e $remotemedia $localmedia ; quit")"

variables
Code:

#!/bin/bash
#Set Variables
export ftpuser="user_name_here"
export ftphost="ftp_host_here"
export ftppass="pass_here"
export remotemedia="/name/music"
export localmedia="/root/media"


suicidaleggroll 06-29-2015 10:48 PM

My guess is it has to do with your nested double quotes in commands (not a terrific name for a script BTW). Does anything change if you switch the inside pair to single quotes?

aristosv 06-30-2015 12:02 AM

this is the result

Code:

::::::::::::::
/root/log/Client38.log
::::::::::::::
Sync

when in fact after the word "Sync" there should be the results of the synchronization process.

aristosv 06-30-2015 12:22 PM

anyone?


All times are GMT -5. The time now is 11:07 PM.