I have the following scripts running on raspbian.
start
#!/bin/bash
/root/config/commands 2>&1 > /root/log/$HOSTNAME.log
commands
#!/bin/bash
source /root/config/variables
echo TestLine
/usr/bin/lftp ftp://user:[email protected] -e "set ftp:ssl-allow no ; set net:reconnect-interval-base 5 ; set net:max-retries 2 ; mirror -e /testgroup/music /root/media ; quit"
/usr/bin/mail -s "$HOSTNAME Report" $emailaddress < $logdir/$HOSTNAME.log``
When I run "start" manually I receive the email below
TestLine
Total: 1 directory, 4 files, 0 symlinks
When I run it using cron, I get the following email
TestLine
This is how crontab -e is set up
@daily /root/start
Any idea why would cron strip the lftp output from the email?
cron does not run with the same environnent as an interactive shell. Your
$HOSTNAME
variable is not set.You can set it at the start of your script like so:
I have spent some time fighting against the problem myself. Decided to go with
screen
. E.g.I had the same issue. lftp simply does not output that line when run from cron, but it still does its job.