You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bitburner-scripts/src/cleanup.ts

19 lines
503 B
TypeScript

import { NS } from "@ns";
import { getControllerState } from "/lib/types-and-constants";
export async function main(ns : NS) : Promise<void> {
const [script] = ns.args
const datafileState = getControllerState(ns)
const adminServers = datafileState.knownServers.filter(s => s.hasAdminRights)
for(const server of adminServers) {
const processes = ns.ps(server.hostname)
for (const process of processes) {
if (process.filename === script)
ns.kill(process.pid)
}
}
}