- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 CronJob 在 Kubernetes 中运行一个 shell 脚本,这是我的 CronJon.yaml 文件:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- /home/admin_/test.sh
restartPolicy: OnFailure
CronJob 已创建(kubectl apply -f CronJob.yaml)当我获得 cronjob 列表时,我可以看到 cron 作业 ( kubectl get cj ),当我运行“kubectl get pods”时,我可以看到正在创建 pod,但 pod 崩溃了。谁能帮助我学习如何在 Kubernetes 中创建 CronJob?
最佳答案
正如评论中正确指出的那样,您需要提供脚本文件才能通过您的 CronJob
执行它。您可以通过将文件安装在 volume 中来做到这一点.例如,您的 CronJob
可能如下所示:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- /myscript/test.sh
volumeMounts:
- name: script-dir
mountPath: /myscript
restartPolicy: OnFailure
volumes:
- name: script-dir
hostPath:
path: /path/to/my/script/dir
type: Directory
上面的例子展示了如何使用 hostPath卷的类型,以便安装脚本文件。
关于kubernetes - 如何在 Kubernetes cronjob 中执行脚本 shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68014653/
我已经安排了一些 cronjob。 当我执行 crontab -e 时,我会找到现有的 cronjobs。 * * * * * #Runs every minute 30 * * * * #Run
在 Linux Ubuntu 上,我有一个 python 脚本,可以在本地按时运行良好,每 5 分钟一次,用于 cronjob: */5 * * * * /usr/bin/python /matt/p
我的服务器上有一些 PHP 脚本,用于定期 cron 作业(例如,用于日常交流和更新排行榜)。 为了防止外人手动运行这些脚本(例如在浏览器中运行 http://url/script.php),我在运行
我的 crons 工作正常,我用简单的文件输出和 bash 脚本对其进行了测试,但在执行我的 python 脚本时,我没有尝试过任何工作。 所以这就是我所做的。 像往常一样,我在脚本中添加了一个 sh
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
本文通过 Google 翻译 Cron Jobs – Linux Privilege Escalation - Juggernaut-Sec 这篇文章所产生,本人仅是对机器翻译中部分表达别扭的字
我有很多 php 脚本,我想作为 cronjob 执行。这些脚本以正确的顺序执行并且不同时运行很重要。如何设置相互运行的 cronjobs? 最佳答案 每个 cron 作业都在计划运行时运行,而不管是
我对 kubernetes 很陌生,在这里我厌倦了一个 cronjob yaml,其中每 1 分钟创建一次 pod。 apiVersion: batch/v1beta1 kind: CronJob m
因此,我设置了一个 cronjob 来运行以下命令: php/var/www/path/to/cron/do-stuff.php 路径是正确的。该目录归 www-data 所有。 该脚本执行以下操作:
我在我的 Centos 7 服务器上运行了 50 多个 cronjob,就像下面给出的那样。 curl -s https://url.com/file.php 每 10 分钟运行一次。从 shell
当我通过 SSH 连接到我的 Ubuntu 6.4 VM 并运行 python nomi.py ,我的脚本按原样执行。 我按如下方式设置了我的 crontab 文件,以便每 15 分钟运行一次脚本:
我正在尝试创建一个遵循以下规则的 cronjob: 周一至周五 8:00 - 16:00 每 2 分钟 所以基本上它必须在周一到周五运行,在 8 点到 16 点之间每隔一分钟运行一次。 在这些时候,它
所以在过去的几分钟里我一直在查找 cronjobs ......我大致了解如何将一个添加到我的网站 ubuntu 系统......我需要让我的系统每分钟运行一次 Jade 米作业(根据到我正在使用的软
我正在冒险进入设置 cronjobs 的世界,并尝试了解更多关于服务器端的信息。为此,我尝试在我的服务器上设置一个 Cronjob,以便在两天内运行两个单独的 Ruby 脚本。 问题: 我将 cron
我有手动运行良好的脚本,但在通过 cronjob 运行时没有获得所需的输出。如果脚本有任何问题,请告诉我。 #!/usr/bin/ksh file1=$(find *-* -mtime 1) file
不确定我做错了什么,但我遇到了 CronJobs 停止安排新作业的问题。似乎只有在启动新作业失败几次之后才会发生这种情况。在我的特定情况下,由于无法拉取容器镜像,Jobs 无法启动。 我并没有真正找到
我创建了一个用于生成 RSS 提要的 php 脚本,该提要最终将通过 Cronjob 运行。 所有 php 文件和生成的 RSS xml 都将位于网站的子文件夹中。如果我在本地开发机器上的同一目录中使
我在这里检查了一种解决方案,但似乎找不到。我正在处理大约300kb / sec的非常慢的wan连接。对于我的下载,我使用的是远程盒,然后将其下载到我的房子。我正在尝试运行一个cronjob,它将每小时
我希望每 15 分钟触发一次作业,但它始终每 30 分钟触发一次。 更新: 我通过运行简化了问题: kubectl run hello --schedule="*/1 * * * *" --resta
我有一个时间表: schedule: "0 10,14,18 * * *" ,我想在上午 10:00、下午 2:00、下午 6:00 运行此作业。 由于我位于 UTC+8 时区,因此这个 cronjo
我是一名优秀的程序员,十分优秀!