由于openoffic文件故障时就会崩溃,后来到网上找到了自动启动的方法
下面地址是原贴
解决openoffice进程异常退出的办法
- 编写脚本
openoffice.sh
#!/usr/bin/bash
OPENOFFICEPID=`ps -ef|grep "/opt/openoffice4/program/soffice"|grep -v grep|grep -v grep|awk '{print $2}'`
if [ ! -n "$OPENOFFICEPID" ];then
echo "OPENOFFICEPID is empty"
echo "start openoffice"
nohup /opt/openoffice4/program/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;StarOffice.Service" -nofirststartwizard &
else
echo "OPENOFFICEPID is $OPENOFFICEPID is started!"
fi
如果文件是在Windows环境中编写的,因为window是的换行与Linux的换行是不同的 脚本会报错 上传到Linux后 执行: bash openoffice.sh 查看是否能正常运行 :sed -i ‘s/\r$//’ openoffice.sh 命令可以将Windows的换行符替换成空白
- 将openoffice.sh脚本放置在root目录下面,当然也可以放在其他位置
- 授权: chmod a+x openoffice.sh
- 编辑crontab 文件
[root@localhost ~]# cd /var/spool/cron
[root@localhost cron]# crontab -e
编辑内容如下
* * * * * /root/openoffice.sh
5.验证:
查看当前openoffice运行情况
[root@localhost cron]# ps -ef|grep 8100
将openoffice所有进程杀掉
ps -ef|grep “/opt/openoffice4/program/soffice”|grep -v grep|grep -v grep|awk ‘{print $2}’ | xargs kill
大概一分钟后 运行下面命令查看脚本是否执行
[root@localhost cron]# ps -ef|grep 8100