不过只考虑给CPU和内存加压,网络方面基本上必定要依赖其他组件了。比如自己装个speedtest,弄个cron任务定时跑一跑。
[ol]memt_size=$(free -m|awk '/^Mem/{print int($2/4)}');
free_size=$(free -m|awk '/^Mem/{print int($4/2)}');
((mem_size>free_size)) && block_size=${free_size} || block_size=${memt_size}
[[ "$(uname -m)" == "aarch64" ]] || block_size=1;
cpuq=$(lscpu | awk '/^CPU\(/{print $NF*100/4}');
echo "[Unit]
Description=stange oracle cloud free tier instance keepalive
[Service]
Type=simple
ExecStartPre=/usr/bin/dd if=/dev/zero of=/dev/shm/mem.img bs=1M count=${block_size}
ExecStart=/usr/bin/dd if=/dev/zero of=/dev/null
ExecStopPost=/bin/rm -f /dev/shm/mem.img
CPUQuota=${cpuq}%
[Install]
WantedBy=multi-user.target" > /lib/systemd/system/cpur.service
systemctl daemon-reload;
systemctl enable cpur --now;
systemctl restart cpur;[/ol]复制代码