Oracle Keep-Alive Scripts
Oracle has started reclaiming idle instances. Free instances with low utilization may be cleaned up. If, within seven days, all of the following conditions are met, Oracle will treat the free instance as idle and reclaim it:
- CPU utilization is below 10% for 95% of the time
- Network utilization is below 10%
- Memory utilization is below 10% (A1 shape only, i.e., ARM instances)
Official announcement: https://docs.oracle.com/en-us/iaas/Content/FreeTier/freetier_topic-Always_Free_Resources.htm
Oracle Cloud is going to clean up idle instance resources. Many people use Oracle free VPS instances for websites, proxies, or SSR/V2Ray airports; it would be a pity if they got deleted. How do you keep Oracle Cloud free VPS servers alive? Here is a collection of Oracle free instance keep-alive tutorials for you to try.
Keep Alive by Computing Pi to Burn CPU
nohup echo "scale=99999999;4*a(1)" | bc -lq > /dev/null &nohup cpulimit -l 30 -p 22489 >/dev/null &scale那个代表小数点后的位数,数越大计算时间越长-l 那里可以控制cpu使用率0-200-p 那里写程序的PID,通过top命令查找,或者 ps -aux | grep bc运行以上指令后,执行 exit 命令,再关闭窗口退出 xshell,后台命令不会终止或者直接 Shell 死循环:nohup cpulimit -l 30 bash -c "while :;do a=1;done" > /dev/null 2>&1 &如果报错,安装一下bcapt install bc -y && apt install cpulimit -yExplanation of the Chinese comments above:
scalecontrols the number of digits after the decimal point; the larger the value, the longer the computation takes.-lcontrols CPU usage, range 0–200.-pis the PID of the program; find it viatoporps -aux | grep bc.- After running the commands above, run
exitand close the Xshell window; the background command will keep running. - Or use a simple shell infinite loop instead (see the
whileexample above). - If you see errors, install
bcandcpulimitwith the last line.
Oracle Cloud One-Click Keep-Alive Script (I)
NeverIdle project: https://github.com/layou233/NeverIdle
# Install wget and screen on the serveryum install -y wget screen# Download the precompiled binary# AMD serverswget https://github.com/layou233/NeverIdle/releases/download/0.1/NeverIdle-linux-amd64 -O NeverIdle# ARMwget https://github.com/layou233/NeverIdle/releases/download/0.1/NeverIdle-linux-arm64 -O NeverIdle# Change file permissionschmod 777 NeverIdle# Run the program with screenscreen -R baohuo# Start the program./NeverIdle -c 2h -m 2 -n 4h# Detach from screen with Ctrl+A+D# Reattach to screen laterscreen -R baohuoCommand parameters:
./NeverIdle -c 2h -m 2 -n 4hExplanation:
-
-cenables periodic CPU waste. The value is the interval between each run, e.g.,12h23m34smeans waste CPU once every 12 hours 23 minutes 34 seconds. Follow this format. -
-menables memory waste. The value is a number in GiB. After startup, it allocates and holds that amount of memory until you manually kill the process. -
-nenables periodic network waste. The value is the interval between each run, same format as CPU. It periodically runs an Ookla Speed Test (and prints the results).
Oracle Cloud One-Click Keep-Alive Script (II)
Project: Oracle one-click auto workout
Starting at midnight every day, this script lets the CPU “work out” automatically for 600 seconds every 3 hours, running 8 times per day (a total of 80 minutes, with 10%–20% load), meeting the requirement that CPU utilization be above 10% for at least 5% of the time (>= 72 minutes per day). You can adjust the workload as needed.
If you use the BaoTa panel, you can also leverage its built-in scheduled tasks. Oracle one-click keep-alive code:
# AMD versioncd /root && wget https://raw.githubusercontent.com/velor2012/lookbusy-docker/main/lookbusy -O lookbusy && chmod +x lookbusy && sudo echo "0 */3 * * * root timeout 600 /root/lookbusy -c 10-20 -r curve" >> /etc/crontab && grep -q centos /etc/os-release && service crond restart || service cron restart# ARM versioncd /root && wget https://raw.githubusercontent.com/velor2012/lookbusy-docker/main/lookbusy-arm -O lookbusy && chmod +x lookbusy && sudo echo "0 */3 * * * root timeout 600 /root/lookbusy -c 10-20 -r curve" >> /etc/crontab && grep -q centos /etc/os-release && service crond restart || service cron restartCheck logs:
cat /var/log/cron | grep lookbusyOne-click uninstall:
sed -i "/lookbusy/d" /etc/crontab && rm -f /root/lookbusy && grep -q centos /etc/os-release && service crond restart || service cron restartOracle Cloud One-Click Keep-Alive Script (III)
Oracle-server-keep-alive-script project: Oracle-server-keep-alive-script
All resources are consumed dynamically and adjusted in real time, so if some resource on the server has already exceeded its threshold, the script won’t keep pushing it further.
Supported systems: currently verified on Ubuntu with no issues; other mainstream systems should also work.
Optional resources to consume: CPU, memory, bandwidth.
After installation, wait 5 minutes and check the utilization (initial CPU load parameters are low, so a shorter time may not show much load). If after more than 10 minutes there is still no noticeable utilization, uninstall the script and report the issue.
Because updates may be cached, you need to wait for the CDN to load the latest script. Pay attention to the script’s current update date: 2023.02.04.
Option 1 installs, option 2 uninstalls, and option 3 exits the script. During installation, pressing Enter directly for all prompts will enable all optional resource consumption. If you don’t want a particular resource consumed, type n and then Enter.
At the end, you’ll be asked whether to customize the bandwidth consumption parameters. The default is n; press Enter to use the default configuration. Type y and press Enter to customize according to the prompts.
curl -L https://raw.githubusercontent.com/spiritLHLS/Oracle-server-keep-alive-script/main/oalive.sh -o oalive.sh && chmod +x oalive.sh && bash oalive.shor
bash oalive.shor
bash <(wget -qO- --no-check-certificate https://raw.githubusercontent.com/spiritLHLS/Oracle-server-keep-alive-script/main/oalive.sh)Script notes:
-
CPU consumption has two modes: prime-number calculation and scientific computation. You can choose freely. The target load range is 15%–25%.
-
CPU consumption is dynamic: it checks every few seconds, adjusts the computation task accordingly, and even the check interval is dynamically adjusted.
-
CPU consumption has double safeguards: in addition to dynamic adjustment, a maximum load is set in the daemon. By default the maximum is 30% (or
cores * 13%if that’s lower than 30%). -
Memory consumption is set to use 20% of total memory, running for 300 seconds and then resting for 300 seconds.
-
Memory consumption is checked every 300 seconds. The amount of memory consumed is dynamically adjusted; if your memory usage already exceeds 20%, it won’t allocate more.
-
Bandwidth consumption downloads a 1–10 GB file every 45 minutes, just to occupy bandwidth. It only downloads and does not save the file, so it does not use disk space.
-
Bandwidth consumption dynamically adjusts the actual download bandwidth/rate, limiting each run to a maximum of 10 minutes. Before each download, it tests the maximum available bandwidth and then adjusts to use 20% of it.
-
Resource usage is managed with daemons and systemd services, ensuring the workload continues and remains effective.
-
You can choose a one-click uninstall for all resource consumption services. Uninstalling removes all scripts and services, including cron jobs, daemons, and startup services.
This script periodically wastes resources and can be used to keep Oracle instances alive. It is designed to counter Oracle’s latest idle-instance reclaim mechanism.