Pat*_*ryk 6 shell bash defaults tmux
我有一个 crontab,它启动 tmux-launching-script,如下所示:
-sh-3.00# crontab -l
@reboot /root/scripts/tmux_autostart.sh
Run Code Online (Sandbox Code Playgroud)
在哪里
#!/bin/bash
# setup tmux session
tmux new -d -s my_session
Run Code Online (Sandbox Code Playgroud)
但是当系统启动时,我没有常规提示符,而是shell提示符:
-sh-3.00#
Run Code Online (Sandbox Code Playgroud)
如果我的配置.tmux.conf中已经有这个,如何将其更改为 bash
set-option -g default-shell /bin/bash
Run Code Online (Sandbox Code Playgroud)
编辑
-sh-3.00# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
Run Code Online (Sandbox Code Playgroud)
你的@reboot
工作在 root 的 crontab 中。crontab 中设置的变量仅适用于该 crontab,因此 中的设置/etc/crontab
对 root 的 crontab 执行的作业没有影响。
Cron 中的默认 shell 是/bin/sh
,SHELL
环境变量设置为/bin/sh
除非被覆盖。所以 Tmux 以 开头SHELL=/bin/sh
。
看起来你的版本/bin/sh
是 Bash 3.00。提示符表明 bash 是作为登录 shell 启动的,并且没有设置初始化文件PS1
(可能根本没有初始化文件)。
如果您设置default-shell
in ~/.tmux.conf
,则该变量优先于SHELL
环境变量。我怀疑您没有显示.tmux.conf
在根目录的主目录中,而是显示在其他位置,也许是您自己的主目录。
您可以选择SHELL=/bin/bash
在 root 的 crontab 中进行设置,或者.tmux.conf
在 root 的主目录中写入文件。