在Linux中进行用户登录身份验证后如何运行脚本 [英] How to run a script after user login authentication in linux
问题描述
我有一个脚本,希望在用户登录身份验证后立即运行.为此,我在/etc/rc5.d/S##rc.local
文件中添加了脚本名称.但是后来我才知道,添加到rc.local文件中的任何内容都会在系统启动时执行,而不是在登录身份验证之后执行.谁能告诉我用户登录身份验证后如何运行脚本?
I have a script which I want to run just after user log-in authentication. To accomplish this, I added the script name in /etc/rc5.d/S##rc.local
file. But later i got to know that, anything that is added in rc.local file gets executed in boot time of the system not after the login authentication. Can anyone tell me how to run the script after user login authentication?
推荐答案
或者,您可以将脚本添加到/etc/profile.d
文件夹.
Alternatively, you can add your script to /etc/profile.d
folder.
在此处和基本上,您应该给脚本扩展名 .sh ,因为所有这些文件都是在用户登录后循环执行的.
Basically, you should give your script the extension .sh as all these files are executed in a loop after user logs on.
这篇关于在Linux中进行用户登录身份验证后如何运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!