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

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

思有云 - IOIOX

整理 Ultra Mobile PayGo 注册使用过程中的一些常见问题和技巧 - 思有云 RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。 - 思有云 香港两日行 - 汇丰香港 招商永隆 福途牛牛 快速办卡经验分享 - 思有云 Sink - 免费部署在 Cloudflare Pages 上的超好用的短链接服务 - 思有云 分享个人的二手 iPhone 验机流程 2025 - 思有云 docker 部署 Epusdt - 独角数卡 dujiaoka 的 usdt 支付插件 - 思有云 CentOS 7 安装 WireGuard 详细教程 - 思有云 注册使用 Depay 虚拟信用卡开通 ChatGPT Plus 教程 - 思有云 docker 部署 nali 开源 IP 地理信息归属查询软件 - 思有云
甲骨文云 Oracle Cloud 服务器防回收保活 docker 命令 - 思有云
博主: Stille · 2024-01-19 · via 思有云 - IOIOX

简介

近期甲骨文出台了政策,将对闲置的服务器进行停机或者回收处理,为了防止被删,网上各路大神也出了很多教程来让服务器高负载,不过大多数都是试用 shell 脚本循环计算,dd 复制空文件或者一些类似 lookbusy 等第三方软件来模拟高负载。

不过作为洁癖党,总是会避免安装一些不太了解的第三方软件,也但是一些脚本后台运行出问题,或者时间长了忘记了,所以还是觉得把脚本跑在 docker 里最合适,也最方便管理。可以做到想开就开,想关就关,还可以配合 crontab 定时开关。

更多甲骨文云 Oracle Cloud 相关技巧,教程及信息,请持续关注甲骨文云 Oracle Cloud 系列文章汇总:

本文为 Stille 原创文章.经实践,测试,整理发布.如需转载请联系作者获得授权,并注明转载地址.


教程

原理很简单,就是写了一段最简单的循环计算 shell 脚本,在 alpine 容器内部执行。只需要控制 docker 的启动和停止即可。

注意:本服务脚本仅占用 CPU 资源,甲骨文政策大概率满足其一即可。

CPU 占用效果

启动此容器后 CPU 占用大致效果图

docker

启动命令

docker run -d --name keeporaclealive --rm alpine sh -c "while true; do for i in {1..100000}; do j=$((i*i)); done; done"

停止命令

docker stop keeporaclealive

注意:上述启动命令加入了--rm参数,停止容器将自动删除容器,不会残留到系统中。

docker 常驻

启动命令

docker run -d --name keeporaclealive --restart always alpine sh -c "while true; do for i in {1..100000}; do j=$((i*i)); done; done"

上述命令将容器常驻,即使服务器重启也会自动启动服务。

停止命令

docker stop keeporaclealive
# 停止服务,容器不会被删除。
docker start keeporaclealive
# 再次启动容器。
docker rm keeporaclealive
# 停止后彻底删除容器。

docker compose

同时也可以用 docker compose 来管理,这样启动和停止命令会更加方便。

mkdir keeporaclealive
cd keeporaclealive
vi docker-compose.yml
# 创建 keeporaclealive 目录并新建 docker-compose.yml 文件,复制以下配置文件。

docker-compose.yml

version: '3'
services:
  keeporaclealive:
    image: alpine
    command: 'sh -c "while true; do for i in $$(seq 1 100000); do j=$$[i*i]; done; done"'
    restart: always

启动和停止可以用以下命令控制:

docker-compose up -d
# 启动
docker-compose down
# 停止

crontab 定时任务,每日 10 点启动,每日 14 点停止。
根据自身情况修改 /root/keeporaclealive 目录地址

crontab -e
# 添加以下两条记录
0 10 * * * cd /root/keeporaclealive && /usr/local/bin/docker-compose up -d
0 14 * * * cd /root/keeporaclealive && /usr/local/bin/docker-compose down

结语

更多甲骨文云 Oracle Cloud 相关技巧,教程及信息,请持续关注甲骨文云 Oracle Cloud 系列文章汇总:


晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. 晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。
RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。

赞赏作者

如果喜欢我的文章,觉得对你有帮助,请随意赞赏!