创建临时 systemd unit 并运行命令
systemd-run 可以启动 transient service/scope/timer,适合临时资源限制、后台任务和定时任务,不必手写 unit 文件。
systemd-run --unit=backup --on-active=10m /opt/app/backup.sh
systemd-run --scope -p CPUQuota=50% ./batch
systemd-run --user --unit=test sleep 60
--user)是两套实例;日志和权限不同。--setenv/Environment=。--scope 在当前会话运行,--service 由 systemd 管理;生命周期不同。journalctl -u <unit>;先确认 unit 名。