crontab方式
先查看是否有cron
bash
systemctl status crond

没有的话就安装
bash
yum install cronie
打开你的crontab文件进行编辑。使用以下命令打开当前用户的crontab文件:
crontab -e
bash
* * * * * /export/test.sh >> /export/test.log 2>&1
/export/test.sh
bash
#!/bin/bash
echo 'test task'

想删除任务只需要 crontab -e去删除即可,也可以多个任务
bash
* * * * * /export/test.sh >> /export/test.log 2>&1
* * * * * /export/test1.sh >> /export/test1.log 2>&1
cron方式
先查看是否有cron
bash
systemctl status crond

没有的话就安装
bash
yum install cronie
在/etc/cron.d文件夹下面添加文件即可,我添加了一个mycron
bash
* * * * * root echo "Hello from cron" >> /export/cron.log 2>&1
* * * * * root cd /export;./cyz.sh >> /export/cron.log 2>&1

删除任务只需要删除指定行,或整个文件