shell - Writing a cronjob using a script
问题描述
This is the first time I am trying to setup the cronjob to automatically do updates in Jenkins. Currently, I have done the following so far:
1. sudo crontab -e # opens the cron tab which will/should put the file in /var/spool/cron
2. @daily yum update # running the updates daily
This fixes the issue but
- when I try to do
sudo cd /var/spool/cron
I cannot see anycrontab
. But when I dosudo crontab -l
it shows me@daily yum updates
- How can I write the content
@daily yum updates
tocrontab
via script (like cloud init script)?
解决方案
一种方法是——
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "@daily yum updates" >> mycron
#install new cron file
crontab mycron
rm mycron
推荐阅读
- python - 如何在python中将日期从循环交换到数组?
- vue.js - 如何在组件 vuejs 中显示带有插槽的原始 html
- ionic4 - 类型“SQLiteOriginal”不可分配给类型“Provider”
- wordpress - 为什么您与本网站的连接不是私密的
- firebase - 如何从 Flutter 退出 Google Auth?
- pandas - 如何在某个描述上提取多个关键字
- python-3.x - 如何在熊猫中添加具有移动日平均值的条件?
- python - 如何在python中将字符串转换为列表
- node.js - 如何异步使用 node-addon-api 的 AsyncContext
- sql - 根据 SQL Server 中计算的总数计算每行的百分比值