[英]How to run last and print my script output during boot with systemd?
I'm trying to configure my host during deployment process and to give an output to the screen of what my configuration script is doing. 我正在尝试在部署过程中配置我的主机,并在屏幕上输出我的配置脚本正在执行的操作。
In RHEL6 it was easy i was echoing what I want to screen or used dialog to display the output, and only when my script was done i got the login prompt. 在RHEL6中我很容易回应我想要屏幕或使用对话框来显示输出,只有当我的脚本完成后我才能获得登录提示。
In RHEL7 i can't mimic this process. 在RHEL7中,我无法模仿这个过程。 rc.local does not display my output during booting and also its not guaranteed it will run last. rc.local在引导期间不显示我的输出,也不保证它将在最后运行。
I guess I need to create a systemd service file that will run my script. 我想我需要创建一个运行我的脚本的systemd服务文件。
But how do I output the result to the screen while booting? 但是如何在启动时将结果输出到屏幕?
And how do I make sure I will not get the log-in prompt before my script ends? 如何确保在脚本结束之前我不会收到登录提示?
below service example works like a charm :) 下面的服务示例就像一个魅力:)
[Unit] Description=ldt_bootscript1.service After=network.target Before=getty@tty1.service [Service] Type=oneshot ExecStart=/bin/bash -c "/bin/bash /tmp/ldt_scripts/postinstall/rc.firstboot.qas | /usr/bin/dialog --clear --backtitle \\"Linux Deployment\\" --title \\"tests\\" --progressbox 20 70 > /dev/console 2>&1" ExecStartPre=/usr/bin/echo -e \\033%G ExecReload=/bin/kill -HUP $MAINPID RemainAfterExit=no WorkingDirectory=/ Environment=TERM=xterm [Install] WantedBy=multi-user.target
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.