mac 定时任务
2016-03-23 14:33
471 查看
linux下面定时执行一个脚本只需要crontab或者at以下就好了.mac上是是什么?怎么运行一个任务?
首先,你要写一个任务.
其次,让这个任务定时执行.
简单的写一个任务get_time.sh
#!/bin/bash date >> /Users/twocucao/Downloads/dates.txt
创建一个特殊的xml文件叫做com.apple.getdates.plist(名字可以自己定义)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.apple.getdates</string> <key>ProgramArguments</key> <array> <string>/Users/apple/get_time.sh</string> </array> <key>StartInterval</key> <integer>10</integer> </dict> </plist>
拷贝到LaunchDaemons,加载定时工作,然后检查是否加载成功
sudo cp com.apple.getdates.plist /Library/LaunchDaemons launchctl load -w /Library/LaunchDaemons/com.apple.getdates.plist launchctl list | grep getdates
验证是否生效
tail -f /Users/apple/dates.txt
由于这个脚本仅仅是为了演示,所以,记得把他给卸载,删除
launchctl unload -w /Library/LaunchDaemons/com.apple.getdates.plist rm /Library/LaunchDaemons/com.apple.getdates.plist
相关文章推荐
- 微服务
- Android:Mac下WebView的debug
- Application Express中的resultful服务的插入语句
- 基于TestNG 与Selenium 的自动化测试设计与实施
- mysql修改max_allowed_packet
- HDU 2546 饭卡
- 500 G JAVA视频网盘分享
- Eclipse theme 配置
- Django表单简介
- Android 快速开发系列 打造万能的ListView GridView 适配器
- [ios]http无法链接
- 举例讲解Android中ViewPager中的PagerTitleStrip子控件
- 高斯模糊效果的简单实现
- Dubbo基础篇_01_CentOS安装jdk,Tomact环境
- ubuntu的mysql卸载与安装
- React-Native(二)引入项目,在windows上运行已有的Demo for Android
- mysql求某个列的前10条记录的总和
- jquery编写web页面头部分类的选中事件$.cookie("currentIndex", index, { path: '/'});
- 不受支持的URL Statue Code 1002
- SpringMVC helloworld