Hi everybody,
I am not totally new to OMV, but until now I have only been using straight forward and easy cases.
Due to some architectural changes I decied to reinstall OMV. I was using OMV 6 and did a brand new install from OMV ISO to OMV 7.1.0-2.
After setting everything up as I documented, all services are working like a charm.
The last thing I am having an issue with is:
I am having 4 bash scripts which work fine while executed as root in a terminal (ssh) and while the job are planned with crontab. When setting up the same jobs with "System --> Scheduled Tasks" and starting them manually, I allways get the following error
500 - Internal Server Error Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sb...
Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; export LANGUAGE=; export SHELL=/bin/sh; sudo --shell --non-interactive --user='root' -- /var/lib/openmediavault/cron.d/userdefined-ccf398f3-e7aa-40cd-aac1-801c6e9be89b 2>&1' with exit code '1':
OMV\ExecException: Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; export LANGUAGE=; export SHELL=/bin/sh; sudo --shell --non-interactive --user='root' -- /var/lib/openmediavault/cron.d/userdefined-ccf398f3-e7aa-40cd-aac1-801c6e9be89b 2>&1' with exit code '1': in /usr/share/openmediavault/engined/rpc/cron.inc:198
Stack trace:
#0 /usr/share/php/openmediavault/rpc/serviceabstract.inc(622): Engined\Rpc\Cron->Engined\Rpc\{closure}()
#1 /usr/share/openmediavault/engined/rpc/cron.inc(176): OMV\Rpc\ServiceAbstract->execBgProc()
#2 [internal function]: Engined\Rpc\Cron->execute()
#3 /usr/share/php/openmediavault/rpc/serviceabstract.inc(122): call_user_func_array()
#4 /usr/share/php/openmediavault/rpc/rpc.inc(86): OMV\Rpc\ServiceAbstract->callMethod()
#5 /usr/sbin/omv-engined(544): OMV\Rpc\Rpc::call()
#6 {main}
Display More
One example script is:
#!/bin/bash
# kleines script um meine Daten vom Web-Server zu sichern
# Dieses script sollte hier liegen = /root/<DATEI>.sh
# und es sollte ein cronjob eingeplant werden. Wie folgt:
##copy all known an important files from the web server to local.
#5 3 * * * /root/<DATEI>.sh
# Variablen
LOGFILE=/root/MakePleskFullBackup.log
DESTDIR=/srv/dev-disk-by-uuid-<LONG_UUID>/<DIR>/<PATH>
SOURCEUSER=<USER>
SOURCEHOST=<SERVER>.<DOMAIN>
SOURCEDIRBAK=/<WEB_SERVER_DIR>/plesk_backup
DESTDIRBAK=/srv/dev-disk-by-uuid-<LONG_UUID>/<DIR>/<PATH2>
# Aktionen
echo "Subject: Log des 4 Stuendlichen Mail und Hosting Backup." > ${LOGFILE}
echo "$(date) - Starte den Backup Job." >> ${LOGFILE}
# Prepare local directory to save Backup in
mkdir -p ${DESTDIRBAK} >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
echo "$(date) - Verzeichnis, ${DESTDIRBAK}, nicht erstellt." >> ${LOGFILE}
else
echo "$(date) - Verzeichnis, ${DESTDIRBAK}, erstellt." >> ${LOGFILE}
fi
# Start incremental on remote host
ssh ${SOURCEUSER}@${SOURCEHOST} 'sudo /<WEB_SERVER_DIR>/StartFullPleskBackup.sh' >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
echo "$(date) - Konnte StartFullPleskBackup.sh nicht starten/ausfuehren/beenden." >> ${LOGFILE}
exit 1
else
echo "$(date) - Das StartFullPleskBackup.sh wurde erfolgreich ausgefuehrt." >> ${LOGFILE}
fi
# Copy full backup file to local
rsync -chazP --stats --del ${SOURCEUSER}@${SOURCEHOST}:${SOURCEDIRBAK}/server-full* ${DESTDIRBAK}/. >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
echo "$(date) - Konnte ${SOURCEDIRBAK}/server-full* nicht kopieren." >> ${LOGFILE}
exit 1
else
echo "$(date) - Die ${SOURCEDIRBAK}/server-full* wurden erfolgreich kopiert." >> ${LOGFILE}
fi
# remove files older than 8 Days
find ${DESTDIRBAK}/ -name "server-full*" -type f -mtime +8 -delete >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
echo "$(date) - Dateien aelter als 8 Tage ${DESTDIRBAK}/server-full* nicht geloescht." >> ${LOGFILE}
else
echo "$(date) - Die Dateien im ${DESTDIRBAK}/server-full* aelter als 8 Tage, wurden geloescht." >> ${LOGFILE}
fi
# Adapt files permissions in local directory
chown -R <USER>:users ${DESTDIRBAK} >> ${LOGFILE} 2>&1
if [ $? -ne 0 ]; then
echo "$(date) - Konnte die Berechtigungen am ${DESTDIRBAK} nicht setzen." >> ${LOGFILE}
else
echo "$(date) - Die Berechtigungen vom ${DESTDIRBAK} wurden erfolgreich gesetzt." >> ${LOGFILE}
fi
# Copy the logfile into the dir where all other files are.
cp ${LOGFILE} ${DESTDIR}/.
#sendmail <empfaenger>@<DOMAIN> < ${LOGFILE}
Display More
When executing the script in Terminal the total runtime is about 8 to 9 minutes.
I hope someone can help me with this.
Regards.