A start/stop/status Script
/home/student/indexer/run.sh is a long-running worker. Write the control script /home/student/bin/svc.sh for it:
svc.sh start|stop|status|restart
start: if the worker isn't running, start /home/student/indexer/run.sh in the background, write its PID to /home/student/indexer/worker.pid, print started and exit 0. If it is already running, print already running and exit 0 without starting a second one.stop: stop the worker if it runs, remove the PID file, print stopped, exit 0 (also when it wasn't running).status: print running and exit 0, or print stopped and exit 3. A PID file left behind by a worker that died counts as stopped.restart: stop, then start; exit 0.usage: svc.sh start|stop|status|restart to stderr and exit 2.About this machine
Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.
Part of Shell Scripting for Automation. Next step: Colours Only for Humans
Teaching or writing about this? Embed this lab on your page
Your machine is ready to start
A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.
No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.