请帮忙!我无法弄清楚这个bash脚本有什么问题。它运行良好一天,但现在我每次运行它时都会遇到分段错误错误。我对bash并不擅长,所以我真的不知道有什么规则可以打破这里,也不知道我打破了它们。我确实查找了递归的定义,但似乎我没有在这个脚本中调用这个脚本,所以我觉得我在那里很安全。 (如果我错了,请纠正我)
#!/bin/sh
HTMLFILE=/var/www/vhosts/edu.critiqueit.com/tmp/convertdocs/test_doc.html
DOCXFILE=/var/www/vhosts/edu.critiqueit.com/tmp/convertdocs/test_doc.docx
LOCKFILE=/var/www/cron/convert_failed.lock
LOGFILE=/var/www/cron/convert_log.txt
if [ ! -e "$DOCXFILE" ]
then
echo "[$(date)] Missing docx file. cannot perform safety check. killing script." >> "$LOGFILE"
exit 1;
fi
if [ -e "$HTMLFILE" ]
then
rm -rf "$HTMLFILE"
echo "[$(date)] File exists. beginning conversion" >> "$LOGFILE"
unoconv -f html "$DOCXFILE"
else
if [ -e "$LOCKFILE" ]
then
rm -rf "$LOCKFILE"
echo "[$(date)] Beginning conversion after server reboot" >> "$LOGFILE"
unoconv -f html "$DOCXFILE"
else
touch "$LOCKFILE"
echo "[$(date)] Conversion failed. restarting server." >> "$LOGFILE"
/sbin/shutdown -r now
fi
fi