Python办公自动化【Windows中定时任务、OS/linux 系统定时任务 、Python 钉钉发送消息、Python 钉钉发送图片】(九)-全面详解(学习总结---从入门到深化)(上)

简介: Python办公自动化【Windows中定时任务、OS/linux 系统定时任务 、Python 钉钉发送消息、Python 钉钉发送图片】(九)-全面详解(学习总结---从入门到深化)

Windows中定时任务



定时任务最主要的功能 ,就是帮助我们在指定的时间运行某个程序或者脚本。比如:


1、定期发送邮件

2、定期统计工资情况

3、定期汇总文件

4、定期清理文件


Windows进入定时任务的方法为: 右键“此电脑”-----> 管理 -----> 系统工具 -----> 任务计划程序


快捷键

Windows 键+R,调出"运行窗口",输入 compmgmt.msc


OS/linux 系统定时任务



crontab


1、-e 编辑工作表

2、-l 列出工作表里的命令

3、-r 删除工作表


crontab 的命令构成为 时间+动作,其时间有分、时、日、月、周 五种,操作符有


1、取值范围内的所有数字

2、/ 每过多少个数字

3、- 从 X 到 Z

4、散列数字


注意

crontab 新增了任务后,重启下服务,命令如下: /etc/init.d/cron restart


案例


实例 1:每 1 分钟执行一次 myCommand


\* * * * * myCommand  


实例 2:每小时的第 3 和第 15 分钟执行


3,15 * * * * myCommand  


实例 3:在上午 8 点到 11 点的第 3 和第 15 分钟执行


3,15 8-11 * * * myCommand  


实例 4:每隔两天的上午 8 点到 11 点的第 3 和第 15 分钟执行


3,15 8-11 */2 * * myCommand


实例 5:每周一上午 8 点到 11 点的第 3 和第 15 分钟执行

3,15 8-11 * * 1 myCommand


实例 6:每晚的 21:30 重启 smb

30 21 * * * /etc/init.d/smb restart


实例 9:每天 18 : 00 至 23 : 00 之间每隔 30 分钟重启 smb

0,30 18-23 * * * /etc/init.d/smb restart


实例 10:每星期六的晚上 11 : 00 pm 重启 smb

0 23 * * 6 /etc/init.d/smb restart


实例 11:每一小时重启 smb

\* */1 * * * /etc/init.d/smb restart


实例 12:晚上 11 点到早上 7 点之间,每隔一小时重启 smb

\* 23-7/1 * * * /etc/init.d/smb restart


Python办公自动化【Windows中定时任务、OS/linux 系统定时任务 、Python 钉钉发送消息、Python 钉钉发送图片】(九)-全面详解(学习总结---从入门到深化)(下):https://developer.aliyun.com/article/1420365

目录
相关文章
|
2月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025080401 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025080401 (Linux, Windows) - 专业渗透测试框架
87 0
|
8天前
|
安全 Ubuntu Linux
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
66 4
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
|
2月前
|
Java Linux Apache
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
129 5
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
|
2月前
|
NoSQL IDE MongoDB
Studio 3T 2025.15 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.15 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
78 1
Studio 3T 2025.15 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
13天前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
221 0
|
21天前
|
安全 Java Linux
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
39 0
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
|
安全 Linux 测试技术
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
77 0
|
2月前
|
安全 Linux C++
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
108 0
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
|
Linux iOS开发 UED
LibreOffice 25.8 (Linux, macOS, Windows) - 自由免费的全能办公套件
LibreOffice 25.8 (Linux, macOS, Windows) - 自由免费的全能办公套件
39 0