The processes I need to run are all long-running processes that won't end (normally).
I'd make them system services using your OS's init system. Let a system designed to manage long running processes manage your long running processes. Why spend your energy reinventing all the features a good init system already has such as auto-restart, log management, and inter-service dependencies?
Let's assume your init system is systemd, which is what modern Red Hat and Debian distros use.
I don't want to just run them on background since I need to see their output.
systemd automatically captures stdout and stderr and saves them in its journal. Commands like systemctl status <service>
and journalctl
provide many ways to view and search the log data. You can filter by severity level, or by time, or many other metadata fields. You can look at output for a single service or combined output from multiple services.
If any of the processes exits I want the rest to be automatically killed as well.
systemd lets you express this with BindsTo=
, Requires=
, or other similar options. See the systemd.unit man page for details.
If I use Ctrl+C or other signal on the main command used to run them, I want to kill all the processes.
You can stop services with systemctl stop <service>
. It'll stop the named service and its dependents.
For a sampling of all the things systemd can do for you peruse its manual: