参考:https://www.cnblogs.com/sxdcgaq8080/p/10730633.html
设置定时任务
查看定时任务:
// 查看定时任务crontab -lOptions:-u <user> define user-e edit user's crontab-l list user's crontab-r delete user's crontab-i prompt before deleting-n <host> set host in cluster to run users' crontabs-c get host in cluster to run users' crontabs-s selinux context-x <mask> enable debugging
crontab -e
// 编辑任务crontab -e// #### 文件内容 ####SHELL=/bin/shPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/npm30 9 * * * /api/index.sh// 分钟 小时 天 月 周 执行的命令// minute - 从0到59的整数// hour - 从0到23的整数// day - 从1到31的整数 (必须是指定月份的有效日期)// month - 从1到12的整数 (或如Jan或Feb简写的月份)// dayofweek - 从0到7的整数,0或7用来描述周日 (或用Sun或Mon简写来表示)// command - 需要执行的命令(可用as ls /proc >> /tmp/proc或 执行自定义脚本的命令)
查看linux 跑定时后的错误信息
tail -f -n 200 /var/spool/mail/root
shell文件
index.sh
#!/bin/bash -ilexcd /api && npm run test
软链关联
ln -s /server/node/node-v12.22.1-linux-x64/bin/node /usr/bin/nodeln -s /server/node/node-v12.22.1-linux-x64/bin/npm /usr/bin/npm
