简体   繁体   English

如何运行最后一次并在启动期间使用systemd打印我的脚本输出?

[英]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中我很容易回应我想要屏幕或使用对话框来显示输出,只有当我的脚本完成后我才能获得登录提示。

  • ( I used rc3.d or rc5.d folder with script name S99.myscript.sh) (我使用了脚本名为S99.myscript.sh的rc3.d或rc5.d文件夹)

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.

相关问题 如何让 systemd 在启动时运行 python 脚本 - How can I make systemd run a python script on boot Systemd 自动化——通过服务在启动时运行 Python 脚本 - Systemd Automation -- Run Python Script on Boot via Service 为什么我的Erlang启动脚本在控制台上运行,但从init系统(sysvinit,upstart,systemd)运行时不起作用? - Why does my Erlang boot script work from console but does not work when run from init system (sysvinit, upstart, systemd)? 如何在 200 台服务器上运行脚本并在堡垒实例终端中打印输出? 我的 bash 脚本挂在远程服务器的 ssh 上 - How to run script on 200 servers and print output in bastion instance terminal? My bash script hangs on ssh to remote server 如何在 systemd Ubuntu 18.04 上启动时自动执行 shell 脚本 - How to automatically execute shell script at startup boot on systemd Ubuntu 18.04 将systemd脚本输出重定向到控制台 - Redirect systemd script output to console 如何在特定系统服务重新启动时触发自定义脚本 - How to trigger a custom script to run whenever a specific systemd service restarts 如何从 systemd 服务运行 node.js 脚本 - How to run node.js script from systemd service linux终端在一段时间后作为systemd脚本运行时冻结脚本输出 - linux terminal freezes script output when it is run as systemd script after some time 如何在运行systemd的计算机上启动时在特定时间加载linux模块 - How to load a linux module at specific time during boot on a machine running systemd
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM