How Scripting and Automation Work in Bitburner
Updated
Scripting is the core mechanic of Bitburner: you write JavaScript programs that run on in-game servers, and those programs perform actions — hacking, growing, weakening, and more — automatically and repeatedly. You advance by automating tasks you would otherwise do by hand, then scaling that automation across more servers and more money. This applies to every player; no prior programming experience is required to start, though comfort with basic JavaScript concepts helps as scripts grow.
What scripts actually do
A script is a file stored in the game's virtual file system. When you run it on a server, it executes in the background, consuming that server's RAM while it works. Scripts can:
- Hack a target server to steal money, with success depending on your hacking level and the target's security.
- Grow a server's money back up after it has been drained.
- Weaken a server to reduce its security level.
- Loop and coordinate — call other scripts, wait on timers, and react to changing conditions.
Because these actions take time and repeat, doing them manually does not scale. A single script running on a loop does the work of dozens of manual clicks, and multiple scripts running in parallel across servers multiply that further.
Creating, running, and managing scripts
The general workflow is the same at every stage:
- Write or edit a script in the game's script editor (or terminal-based editor). The file lives in your home directory or another server you can access.
- Check available RAM on the target server. A script needs enough free RAM to run; if it does not fit, it will not start.
- Run the script from the terminal with the
runcommand, specifying the script name and any arguments (such as the target server). - Monitor it through the terminal, the active scripts view, and the logs the script prints.
- Stop or restart it when conditions change — for example, when a target's security gets too high or you unlock a better server.
A minimal example of the pattern: a script that takes a target hostname as an argument, then repeatedly weakens, grows, and hacks that target in a loop, printing results as it goes. The exact functions and their arguments are documented in the game's own script documentation, which is the authoritative reference for what each call does and what it costs in RAM.
Managing RAM is the real constraint
Every script consumes RAM on the server it runs on, and each server has a fixed amount. This is why automation is a progression system rather than a one-time unlock:
- Early on, you have little RAM, so scripts must be small and simple.
- As you gain access to more servers and upgrade your home machine, you can run larger scripts and more of them.
- Efficient players split work into small scripts (one for weaken, one for grow, one for hack) so each fits in available RAM, rather than one large script that blocks everything else.
If a script refuses to start, low RAM on that server is the most common cause — check free RAM before assuming a bug.
Why automation is central to progress
Bitburner's economy rewards scale. Money from hacking grows with your hacking level, the number of servers you can access, and how efficiently you keep targets at low security and high money. All three improve through automation:
- Consistency — scripts act continuously, including while you are doing something else in the game or away from it.
- Parallelism — the same logic runs on many servers at once, multiplying throughput.
- Compounding — money earned funds upgrades and more servers, which support more scripts, which earn more money.
Manual play hits a ceiling quickly because you cannot click fast enough to keep many targets optimized. Scripts remove that ceiling, which is why the game's own guidance pushes players toward writing their first simple script early rather than grinding by hand.
A practical starting path
If you are new, a workable sequence is:
- Run a single small script against one target to see the hack/grow/weaken cycle in action and watch how security and money respond.
- Split the cycle into separate scripts so each uses less RAM, and run them together on one server.
- Add a loop and a delay so the scripts repeat without manual restarts.
- Expand to additional servers as you gain access and RAM, running the same scripts on each.
- Iterate — measure results in the terminal, adjust timing and targets, and grow the setup.
The main stumbling points are running out of RAM, targeting servers whose security has risen too high (hacks fail more often), and scripts that stop when their loop ends. Each is visible in the terminal output, so check logs first when something behaves unexpectedly.
For exact function names, RAM costs, and command syntax, rely on the in-game documentation and terminal help rather than memory — those are the definitive references and they update with the game.