Tente colocar #!/bin/bash
primeiro. Também tente entrar no diretório e digite ./s3backyupsync.sh
usando o Ubuntu 16. Eu criei este script e coloquei em /root/s3backyupsync.sh
#!/bin/sh
################################################
# Simple script to synchronise data into S3 bucket(s)
# @Author: Per Lasse Baasch (https://skycube.net)
# @Version: 2016-01-27
#############################################
LOCALDIR='/mnt/backups'
S3BUCKET='s3://server-backups/'
MAILLOG=yes
MAILRECEIPIENT='[email protected]'
MAILSUBJECT='Daily S3 Cloud Backup Sync'
#############################################
### Remember start time
CURRENTDATETIME=$(date +%Y-%m-%-d-%H:%M:%S);
### Sync data
s3cmd sync --no-progress --recursive --skip-existing --no-check-md5 $LOCALDIR $S3BUCKET;
### Mailing
if [ "${MAILLOG}" = "yes" ]; then
TMPFILE=/tmp/s3backupsynclog.txt;
echo "STARTED: ${CURRENTDATETIME}" > $TMPFILE;
echo "ENDED : $(date +%Y-%m-%-d-%H:%M:%S)" >> $TMPFILE;
echo '' >> $TMPFILE;
s3cmd du -H $S3BUCKET >> $TMPFILE;
echo '' >> $TMPFILE;
mutt $MAILRECEIPIENT -s "${MAILSUBJECT}. - ${CURRENTDATETIME}" < $TMPFILE;
rm $TMPFILE;
fi
Quando eu tento executá-lo com sudo ou root como root/s3backyupsync.sh
recebo o comando não encontrado. Estou faltando alguma coisa?
Resultados de ls -l /root/s3backyupsync.sh
-rwxr-xr-x 1 root root 1013 Sep 15 15:05 /root/s3backyupsync.sh
Tags scripting