Mac如何使用crontab做定时任务

1、crontab服务的重启关闭,开启

Mac系统下

sudo /usr/sbin/cron start
sudo /usr/sbin/cron restart
sudo /usr/sbin/cron stop  

2、编辑mac的可执行脚本

我们以autoPush.sh为例
进入你脚本文件需要存放的目录

cd /Users/houxin/houxin/公司账号/sh

分别执行以下命令
创建

touch autoPush.sh

修改权限

chmod 755 autoPush.sh

编辑内容

vim autoPush.sh

输入类似于以下的内容

cd /Users/houxin/houxin/公司账号
git add . && git commit -m 'Automatically update and push at %date% %time% by mac'
git pull && git push

3、编辑crontab的定时任务列表

crontab -e

内容如下

1 * * * * * /Users/houxin/houxin/公司账号/sh/autoPush.sh
发布了155 篇原创文章 · 获赞 0 · 访问量 860

猜你喜欢

转载自blog.csdn.net/u013866352/article/details/105397075