我正在尝试在 k8s 中创建一个小型 cronjob,它只是在 busybox 容器中使用curl 执行 HTTP Post。虽然格式是错误的,但我不知道我必须更改什么。
我尝试用谷歌搜索收到的错误消息,并以各种方式更改curl命令的格式,但没有成功。
apiVersion: batch/v1beta1
kind: CronJob
#namespace: test
metadata:
name: test-cron
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: test-cron
image: busybox
args:
- /bin/sh
- -c
- curl "https://test-es01.test.svc.clu01.test.local:9200/logs_write/_rollover" -H 'Content-Type: application/json' -d '{"conditions: {"max_size": "5gb"}}'
restartPolicy: OnFailure
Run Code Online (Sandbox Code Playgroud)
然后我尝试运行该文件:
kubectl -n test apply -f test-cron.yaml
并得到以下错误:
error: error parsing test-cron.yaml: error converting YAML to JSON: yaml: line 20: mapping values are not allowed in this …
我最近开始接触Python,但我很难根据自己创建的正则表达式在目录和匹配文件中进行搜索。基本上,我希望它扫描另一个目录中的所有目录,并找到所有以.zip或.rar或.r01结尾的文件,然后根据它是什么文件运行各种命令。
import os, re
rootdir = "/mnt/externa/Torrents/completed"
for subdir, dirs, files in os.walk(rootdir):
if re.search('(w?.zip)|(w?.rar)|(w?.r01)', files):
print "match: " . files
Run Code Online (Sandbox Code Playgroud) 我正试图从linux命令"passwd"获取日期.我正在做什么,我将用户存储在数组@user中,我想在每个用户上运行命令"passwd -S".当ii运行"passwd -S user1"时,它返回:
user PS 2016-02-16 0 99999 7 -1 (Password set, SHA512 crypt.)
Run Code Online (Sandbox Code Playgroud)
我想出了一个正则表达式,只从该字符串中获取日期,正则表达式如下所示:'
\d{4}-\d{2}-\d{2}
Run Code Online (Sandbox Code Playgroud)
但是当我将它与grep结合起来时,我似乎无法使它工作,它仍然输出"passwd"命令的完整输出.这是代码:
PasswordAge();
sub PasswordAge {
for my $loop (@user) {
my $pass =qx(passwd -S $loop);
my @splitpass = grep {/\d{4}-\d{2}-\d{2}/} $pass;
print @splitpass;
}
}
Run Code Online (Sandbox Code Playgroud)