首先确认服务器是否开启任务计划服务,只有root用户才能对crond服务进行开启和关闭[[email protected] ~]# service crond status
crond (pid 1758) is running...
[[email protected] ~]# service crond stop
Stopping crond: [ OK ]
[[email protected] ~]# su - hongjie
[[email protected] ~]$ service crond status
crond is stopped
[[email protected] ~]$ su - root
[[email protected] ~]# service crond start
Starting crond: [ OK ]
[[email protected] ~]# service crond status
crond (pid 2805) is running...
[[email protected] ~]# su - hongjie
[[email protected] ~]$ service crond status
crond (pid 2805) is running...
开启服务后即可写运行脚本,运行脚本需要x执行权
* * * * * [文件绝对路径]
时间: 2024-12-20 22:49:10