惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
Cloudbric
Cloudbric
C
CERT Recently Published Vulnerability Notes
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
C
Cisco Blogs
T
Tenable Blog
P
Privacy International News Feed
T
The Exploit Database - CXSecurity.com
I
Intezer
AWS News Blog
AWS News Blog
IT之家
IT之家
博客园 - 司徒正美
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 【当耐特】
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
S
SegmentFault 最新的问题
博客园 - Franky
人人都是产品经理
人人都是产品经理
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
H
Hacker News: Front Page
Latest news
Latest news
Scott Helme
Scott Helme
腾讯CDC
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
A
Arctic Wolf
S
Securelist
雷峰网
雷峰网
The GitHub Blog
The GitHub Blog
Project Zero
Project Zero
Google DeepMind News
Google DeepMind News
P
Palo Alto Networks Blog
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
云风的 BLOG
云风的 BLOG
Security Archives - TechRepublic
Security Archives - TechRepublic
The Last Watchdog
The Last Watchdog
WordPress大学
WordPress大学
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 最新话题
S
Schneier on Security
NISL@THU
NISL@THU
Jina AI
Jina AI
M
MIT News - Artificial intelligence

邢平cn's blog

甲骨文密钥 ssh 连不上且忘记登录密码解决方法 让 traefik 代替你的 waf(使用 CrowdSec)+ nginx + acme.sh + mtls-auth 使用 rclone 和 alist 加密和备份你的数据到公有云 邓晓芒《黑格尔辩证法讲演录》读书笔记 如何白嫖和使用 GitHub models 的 LLM(gpt4o 和 Llama-3.1-405b) 提升部署在 cloudflare、vercel 或 netlify 的网站在中国国内的访问速度和稳定性 免费通过 NS1 利用监控宝平台实现实时基于不同运营商的故障转移 记录某一测速网站的 js 逆向的过程 列举几个免费域名和权威 dns 服务器 Hexo 博客折腾 docker 学习笔记 尝试在闲置的 surface pro 4 上运行安卓应用 国内各个 as 自治系统[转] 『现学现忘』Git基础 — 19、在Git中进行忽略文件操作 让在 vpc 中的 aws lambda 函数不通过 nat 获得访问互联网的能力 curl 遇到的坑 你的常用域名被其他 vercel 账号使用的解决方法 解决升级 umamiv2.11 时出现的 P3009 错误 v2ray+ws+tls 太慢解决方法 在 python 中运行 bash 实时输出结果(windows) 在存在父子文件结构情况下使用 python import test
cron 笔记
xingpingcn · 2023-04-01 · via 邢平cn's blog

cron 笔记,包含 cron 不执行 shell 脚本的解决办法

cron 笔记,包含 cron 不执行 shell 脚本的解决办法

也许 shell 脚本本身可以执行,但是 cron 中不能执行,需要像下面这样设置

cron-for-run-per-1h.cron

SHELL=/bin/bash

0 * * * * . /etc/profile;/bin/sh /pathto/run.sh

Note (NOTE)

最后一定要有一个回车!后者会导入失败

run.sh

#!/bin/bash

PATH=/opt/someApp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

LOGS_FILE="/pathto/logs/$(date "+%Y-%m-%d-%H-%M-%S").log"

cd /pathto

docker-compose up >> $LOGS_FILE 2>&1

最后设置到 cron

run.sh

crontab /pathto/cron-for-run-per-1h.cron

Warning (warning)

使用此命令会覆盖之前所有的 cron 任务

如果你不想覆盖之前的,那么就 /etc/cron.d 中新建文件,然后写进去。

Warning (warning)

cron 的话基本必有一个 ?,它仅可存在于 dayofmouth 或者 dayofweek

个人 docker 配置备份

Dockerfile

FROM python:3.11

WORKDIR /bin/test

COPY ./requirements.txt ./

RUN pip install -r ./requirements.txt

ENTRYPOINT [ "python" ]

CMD [ "./test.py" ]

docker-compose.yml

version: '3.8'

services:

enhanced-faas:

build:

context: ./

container_name: enhanced-faas

volumes:

- './:/bin/test'

expose:

- 443,80

command: ./main.py

networks:

- nginx-proxy

networks:

nginx-proxy:

external: true

评论