ubuntu 定时脚本折腾札记
来源:互联网 发布:四级网络课程哪个好 编辑:程序博客网 时间:2024/06/05 19:52
#!/bin/bash
# 不知道要不要加环境变量, 鸟哥上说要.
#PATH=/home/linxd/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
#export PATH
date >> "/home/linxd/Desktop/test.txt"
Linux设置定期执行脚本crontab用法 : 千万千万要记住, 不只是/etc/crontab中要用绝对路径, 连脚本也要用绝对路径
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow usercommand
17 ** * *root cd / && run-parts --report /etc/cron.hourly
25 6* * *roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6* * 7roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 61 * *roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/1 * * * * linxd /home/linxd/Desktop/test.sh
定时脚本没能正确执行:
- 默认情况下 cron jobs 的 log 在 /var/log/syslog,可以通过 grep CRON /var/log/syslog 来查看【1】。
- 对于具体执行是否正确以及脚本执行过程中的一些信息,Linux会通过邮件形式发送到该用户【2】,邮件信息信息在 /var/mail/panjinbo
定时脚本调用GUI:
因为这个脚本需要调用Haroopad(GUI)来进行MD文本的编辑,但是Xhost默认不允许别的图形程序显示在当前屏幕上。出现的错误是这样子的:
`[14720:1104/195401:ERROR:browser_main_loop.cc(162)] Running without the SUID sandbox! `
`[14720:1104/195401:ERROR:browser_main_loop.cc(208)] Gtk: cannot open display: `
解决方案:ubuntu 下使用crontab定时执行java程序
在shell脚本程序GUI命令行之前,加入如下代码:export DISPLAY=:0.0 #启动GUI显示
#!/bin/bash
# 不知道要不要加环境变量, 鸟哥上说要.
#PATH=/home/linxd/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
#export PATH
date >> "/home/linxd/Desktop/test.txt"
Linux设置定期执行脚本crontab用法 : 千万千万要记住, 不只是/etc/crontab中要用绝对路径, 连脚本也要用绝对路径
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow usercommand
17 ** * *root cd / && run-parts --report /etc/cron.hourly
25 6* * *roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6* * 7roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 61 * *roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/1 * * * * linxd /home/linxd/Desktop/test.sh
定时脚本没能正确执行:
- 默认情况下 cron jobs 的 log 在 /var/log/syslog,可以通过 grep CRON /var/log/syslog 来查看【1】。
- 对于具体执行是否正确以及脚本执行过程中的一些信息,Linux会通过邮件形式发送到该用户【2】,邮件信息信息在 /var/mail/panjinbo
定时脚本调用GUI:
因为这个脚本需要调用Haroopad(GUI)来进行MD文本的编辑,但是Xhost默认不允许别的图形程序显示在当前屏幕上。出现的错误是这样子的:
`[14720:1104/195401:ERROR:browser_main_loop.cc(162)] Running without the SUID sandbox! `
`[14720:1104/195401:ERROR:browser_main_loop.cc(208)] Gtk: cannot open display: `
解决方案:ubuntu 下使用crontab定时执行java程序
在shell脚本程序GUI命令行之前,加入如下代码:export DISPLAY=:0.0 #启动GUI显示
- ubuntu 定时脚本折腾札记
- Ubuntu 简单定时提醒脚本
- ubuntu定时执行python脚本
- Ubuntu crontab 定时执行php脚本文件
- Ubuntu crontab 定时执行php脚本文件
- ubuntu下crontab 定时执行php脚本
- ubuntu下开机自动运行脚本、定时运行脚本
- ubuntu下开机自动运行脚本、定时运行脚本 .
- ubuntu下开机自动运行脚本、定时运行脚本
- ubuntu下开机自动运行脚本、定时运行脚本
- ubuntu下开机自动运行脚本、定时运行脚本
- ubuntu下开机自动运行脚本、定时运行脚本
- UBUNTU 12.04札记
- ubuntu双系统安装札记
- 定时脚本
- pyqt4折腾 ubuntu下
- Ubuntu 12.04折腾记录
- ubuntu vps折腾记
- C语言学习中遇到的一些关键字
- iOS部分小技巧 持续更新中
- 【DRP分销资源计划】——oracle无法正常工作的解决办法
- Gradle中SDK版本及versoin版本的含义
- Redis整合Spring综合使用缓存实例
- ubuntu 定时脚本折腾札记
- Java字节码文件虚拟指令集简介
- STM8L051之通过ADC1与DMA读取内部参考电压,求取VDD电源电压---库函数版
- 美团Android自动化之旅—适配渠道包
- 一种解决运行程序报“应用程序配置不正确”的问题
- java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
- git常用命令
- 机器学习笔记(PRML)
- 查找一个字符串数组中两个或两个以上的相同字符串(swfit,oc)