Comments (1)
我们就来搭配几个例子练习看看吧!底下的案例请实际用 dmtsai 这个身份作看看喔!后续的动作才能够搭配起来!
例题:
假若你的女朋友生日是 5 月 2 日,你想要在 5 月 1 日的 23:59 发一封信给他,这封信的内容已经写在 /home/dmtsai/lover.txt 内了,该如何进行?
答:
直接下达 crontab -e 之后,编辑成为:59 23 1 5 * mail kiki < /home/dmtsai/lover.txt
那样的话,每年 kiki 都会收到你的这封信喔!(当然啰,信的内容就要每年变一变啦!)
再来
例题:
假如每五分钟需要执行 /home/dmtsai/test.sh 一次,又该如何?
答:
同样使用 crontab -e 进入编辑:
*/5 * * * * /home/dmtsai/test.sh
那个 crontab 每个用户都只有一个文件存在,就是在 /var/spool/cron 里面啊! 还有建议您:‘执行命令时,最好使用绝对路径,这样比较不会找不到执行文件!’
例题:
假如你每星期六都与朋友有约,那么想要每个星期五下午 4:30 告诉你朋友星期六的约会不要忘记,则:
答:还是使用 crontab -e 啊!
30 16 * * 5 mail [email protected] < /home/dmtsai/friend.txt
真的是很简单吧!呵呵!那么,该如何查询使用者目前的 crontab 内容呢?我们可以这样来看看:
[dmtsai@www ~]$ crontab -l
59 23 1 5 * mail kiki < /home/dmtsai/lover.txt
*/5 * * * * /home/dmtsai/test.sh
30 16 * * 5 mail [email protected] < /home/dmtsai/friend.txt
# 注意,若仅想要移除一项工作而已的话,必须要用 crontab -e 去编辑~
# 如果想要全部的工作都移除,才使用 crontab -r 喔!
[dmtsai@www ~]$ crontab -r
[dmtsai@www ~]$ crontab -l
no crontab for dmtsai
看到了吗? crontab ‘整个内容都不见了!’所以请注意:‘如果只是要删除某个 crontab 的工作项目,那么请使用 crontab -e 来重新编辑即可!’如果使用 -r 的参数,是会将所有的 crontab 资料内容都删掉的!千万注意了!
from my-blog.
Related Issues (20)
- css3新特性介绍 HOT 3
- CSS3特效示例介绍 HOT 2
- 实现antd pro v2的动态路由,基于人人的框架 HOT 1
- Kubernetes核心概念总结 HOT 5
- kubernetes调度之Taints和Tolerations策略
- Kubernetes Rook HOT 1
- kubernet的安装
- Java8新特性介绍 HOT 1
- access_token、refresh_token的原理与实现 HOT 4
- Springboot中filter、interceeptor相关介绍 HOT 9
- spring boot与Redis相关知识集锦 HOT 3
- SQL注入相关主题 HOT 3
- React事件相关文章集锦 HOT 1
- serviceWorker知识点集锦 HOT 3
- Angular系列学习入坑指南
- rxJS的学习 HOT 3
- React&Refs相关技术 HOT 1
- React之PureComponent HOT 2
- Flutter学习指南
- React Native学习系列文章
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from my-blog.