执行我的备份 bash 脚本时,一切顺利,包括执行两行 enscript(在我的情况下,enscript 将日志文件转换为 .html 和 .pdf 格式)。
问题是在 crontab 中执行相同的脚本时运行。enscript 行未执行。除了 enscript 行之外,备份、日志记录等工作正常!(?)
任何建议都值得赞赏。顺便说一句,我的脚本编写技能有点有限,所以我可能忘记了一些东西。
剧本:
#!/bin/sh
# script created by John Nomedal
rm /home/adminuser/Backup_Cakebox_Server.*
timer1=$(date +"%s")
starttime=$(date +"%d %B %Y %T")
echo "Starting backup at $starttime" >> /home/adminuser/Backup_Cakebox_Server.log
echo >> /home/adminuser/Backup_Cakebox_Server.log
rsync -aAXvP --exclude-from '/home/adminuser/rsync-exclude.txt' --delete / /media/adminuser/Backup/cakebox --log-file=/home/adminuser/Backup_Cakebox_Server.log
timer2=$(date +"%s")
stoptime=$(date +"%d %B %Y %T")
echo >> /home/adminuser/Backup_Cakebox_Server.log
echo "Backup finished at $stoptime" >> /home/adminuser/Backup_Cakebox_Server.log
diff=$(($timer2-$timer1))
echo "Backup completed in $(($diff / 3600 )) hours $((($diff % 3600) / 60)) minutes $(($diff % 60)) seconds" >> /home/adminuser/Backup_Cakebox_Server.log
# create html and pdf files
enscript --language=html -pBackup_Cakebox_Server.html Backup_Cakebox_Server.log
enscript Backup_Cakebox_Server.log -o - | ps2pdf - Backup_Cakebox_Server.pdf
cp /home/adminuser/Backup_Cakebox_Server.* /home/adminuser/html/cakebox/
cp /home/adminuser/backup.sh /home/adminuser/html/cakebox/Last_script_used
# last update 010215 incl enscript and rename backuplog.txt to Backup_Cakebox_Server.log and copy of backup.sh to Last_script_used
答案1
固定的,
需要完整路径,
enscript --language=html -p/home/adminuser/Backup_Cakebox_Server.html /home/adminuser/Backup_Cakebox_Server.log
enscript /home/adminuser/Backup_Cakebox_Server.log -o - | ps2pdf - /home/adminuser/Backup_Cakebox_Server.pdf
...抱歉,发了这篇不必要的文章....