登陆后执行程序
<h4>一、用户登录时执行</h4>
<p>1、编辑<code>.profile</code>文件进行编辑:</p>
<pre><code class="language-shell">vim ~/.profile</code></pre>
<p>2、添加启动命令:
在<code>.profile</code>文件的末尾,添加你希望在登录时执行的程序或命令:</p>
<pre><code class="language-shell">/path/to/myprogram &amp;</code></pre>
<ul>
<li>/path/to/myprogram 是你程序的完整路径。</li>
<li>&确保程序在后台运行,不会阻塞其它登录操作。</li>
</ul>
<p>3、保存并退出:
保存更改并退出编辑器。对于<code>vim</code>,可以按<code>Esc</code>,然后输入<code>:wq</code>保存退出。</p>
<p>4、是更改生效:
为使更改立即生效,可以重新登录或者手动加载<code>.profile</code>文件:</p>
<pre><code class="language-shell">source ~/.profile</code></pre>