首先确认服务器是否开启任务计划服务,只有root用户才能对crond服务进行开启和关闭[root@localhost ~]# service crond status
crond (pid  1758) is running...
[root@localhost ~]# service crond stop
Stopping crond:                                            [  OK  ]
[root@localhost ~]# su - hongjie
[hongjie@localhost ~]$ service crond status
crond is stopped
[hongjie@localhost ~]$ su - root
[root@localhost ~]# service crond start
Starting crond:                                            [  OK  ]
[root@localhost ~]# service crond status
crond (pid  2805) is running...
[root@localhost ~]# su - hongjie
[hongjie@localhost ~]$ service crond status
crond (pid  2805) is running...


开启服务后即可写运行脚本,运行脚本需要x执行权


* * * * * [文件绝对路径]


#!/bin/bash
echo  `date` >> /home/sms/hongjie/test.txt