Why the command in .bash_logout can't run after reboot?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Os : debian9.
Create a log file.
touch $HOME/logout.log
Add a command in .bash_logout.
vim .bash_logout
echo $(date) >> $HOME/logout.log
Now login with account name test
,and create /home/test/logout.log
.
I want to write date info in /home/test/logout.log
,why no date info after reboot?
Nothing in /home/test/logout.log after reboot.
bash
add a comment |Â
up vote
1
down vote
favorite
Os : debian9.
Create a log file.
touch $HOME/logout.log
Add a command in .bash_logout.
vim .bash_logout
echo $(date) >> $HOME/logout.log
Now login with account name test
,and create /home/test/logout.log
.
I want to write date info in /home/test/logout.log
,why no date info after reboot?
Nothing in /home/test/logout.log after reboot.
bash
1
You need to be logged in to a user, then when you logout this file gets executed. Hence the namebash_logout
. Can you specify exactly when you wantecho $(date)
to be executed? Also you can just dodate >> $HOME/logout.log
â Hunter.S.Thompson
Jan 31 at 13:30
At reboot to write time info into $HOME/logout.log.
â scrapy
Jan 31 at 13:35
date >> $HOME/logout.log
is enough.
â Tomasz
Jan 31 at 13:42
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Os : debian9.
Create a log file.
touch $HOME/logout.log
Add a command in .bash_logout.
vim .bash_logout
echo $(date) >> $HOME/logout.log
Now login with account name test
,and create /home/test/logout.log
.
I want to write date info in /home/test/logout.log
,why no date info after reboot?
Nothing in /home/test/logout.log after reboot.
bash
Os : debian9.
Create a log file.
touch $HOME/logout.log
Add a command in .bash_logout.
vim .bash_logout
echo $(date) >> $HOME/logout.log
Now login with account name test
,and create /home/test/logout.log
.
I want to write date info in /home/test/logout.log
,why no date info after reboot?
Nothing in /home/test/logout.log after reboot.
bash
edited Jan 31 at 13:44
asked Jan 31 at 13:27
scrapy
317213
317213
1
You need to be logged in to a user, then when you logout this file gets executed. Hence the namebash_logout
. Can you specify exactly when you wantecho $(date)
to be executed? Also you can just dodate >> $HOME/logout.log
â Hunter.S.Thompson
Jan 31 at 13:30
At reboot to write time info into $HOME/logout.log.
â scrapy
Jan 31 at 13:35
date >> $HOME/logout.log
is enough.
â Tomasz
Jan 31 at 13:42
add a comment |Â
1
You need to be logged in to a user, then when you logout this file gets executed. Hence the namebash_logout
. Can you specify exactly when you wantecho $(date)
to be executed? Also you can just dodate >> $HOME/logout.log
â Hunter.S.Thompson
Jan 31 at 13:30
At reboot to write time info into $HOME/logout.log.
â scrapy
Jan 31 at 13:35
date >> $HOME/logout.log
is enough.
â Tomasz
Jan 31 at 13:42
1
1
You need to be logged in to a user, then when you logout this file gets executed. Hence the name
bash_logout
. Can you specify exactly when you want echo $(date)
to be executed? Also you can just do date >> $HOME/logout.log
â Hunter.S.Thompson
Jan 31 at 13:30
You need to be logged in to a user, then when you logout this file gets executed. Hence the name
bash_logout
. Can you specify exactly when you want echo $(date)
to be executed? Also you can just do date >> $HOME/logout.log
â Hunter.S.Thompson
Jan 31 at 13:30
At reboot to write time info into $HOME/logout.log.
â scrapy
Jan 31 at 13:35
At reboot to write time info into $HOME/logout.log.
â scrapy
Jan 31 at 13:35
date >> $HOME/logout.log
is enough.â Tomasz
Jan 31 at 13:42
date >> $HOME/logout.log
is enough.â Tomasz
Jan 31 at 13:42
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
first
echo $(date) >> $HOME/logout.log
can be replace by
date >> $HOME/logout.log
next,
.bash_logout
is run when you disconnect, not when there is a reboot.
A reboot is when you restart host, effectively killing (more or less nicely) all it process, database, webserver and so on.
A logout is when you (or any user) disconnect from interactive session, the host stay up, as well as database and the like.
If you want script to be executed during a schedule shutdown, place then in /etc/init.d
, then have a link like K01-trace-logout
in /etc/rcX.d
where X is your run-level (result of who -r
).
finaly
Be aware that unexpected shutdown (power outage, disk I/O freezing) will leave no trace in log file.
I have a question, would$HOME
in this case be/root
or would it be the the home directory of the user who initiates the reboot, assuming the script is in/etc/rc6.d
.
â Hunter.S.Thompson
Jan 31 at 14:03
@Hunter.S.Thompson No, unless you have way to trap which user start shutdown (by way of sudo for instance)...
â Archemar
Jan 31 at 14:06
add a comment |Â
up vote
1
down vote
You need to run bash as login shell. You need to login as the user and when you log-out from the interactive login shell - the .bash_logout script will be executed.
Command in .bash_logout execute in login shell ,most of time i'm in non-login shell (graphic mode).
â scrapy
Jan 31 at 14:06
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
first
echo $(date) >> $HOME/logout.log
can be replace by
date >> $HOME/logout.log
next,
.bash_logout
is run when you disconnect, not when there is a reboot.
A reboot is when you restart host, effectively killing (more or less nicely) all it process, database, webserver and so on.
A logout is when you (or any user) disconnect from interactive session, the host stay up, as well as database and the like.
If you want script to be executed during a schedule shutdown, place then in /etc/init.d
, then have a link like K01-trace-logout
in /etc/rcX.d
where X is your run-level (result of who -r
).
finaly
Be aware that unexpected shutdown (power outage, disk I/O freezing) will leave no trace in log file.
I have a question, would$HOME
in this case be/root
or would it be the the home directory of the user who initiates the reboot, assuming the script is in/etc/rc6.d
.
â Hunter.S.Thompson
Jan 31 at 14:03
@Hunter.S.Thompson No, unless you have way to trap which user start shutdown (by way of sudo for instance)...
â Archemar
Jan 31 at 14:06
add a comment |Â
up vote
3
down vote
accepted
first
echo $(date) >> $HOME/logout.log
can be replace by
date >> $HOME/logout.log
next,
.bash_logout
is run when you disconnect, not when there is a reboot.
A reboot is when you restart host, effectively killing (more or less nicely) all it process, database, webserver and so on.
A logout is when you (or any user) disconnect from interactive session, the host stay up, as well as database and the like.
If you want script to be executed during a schedule shutdown, place then in /etc/init.d
, then have a link like K01-trace-logout
in /etc/rcX.d
where X is your run-level (result of who -r
).
finaly
Be aware that unexpected shutdown (power outage, disk I/O freezing) will leave no trace in log file.
I have a question, would$HOME
in this case be/root
or would it be the the home directory of the user who initiates the reboot, assuming the script is in/etc/rc6.d
.
â Hunter.S.Thompson
Jan 31 at 14:03
@Hunter.S.Thompson No, unless you have way to trap which user start shutdown (by way of sudo for instance)...
â Archemar
Jan 31 at 14:06
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
first
echo $(date) >> $HOME/logout.log
can be replace by
date >> $HOME/logout.log
next,
.bash_logout
is run when you disconnect, not when there is a reboot.
A reboot is when you restart host, effectively killing (more or less nicely) all it process, database, webserver and so on.
A logout is when you (or any user) disconnect from interactive session, the host stay up, as well as database and the like.
If you want script to be executed during a schedule shutdown, place then in /etc/init.d
, then have a link like K01-trace-logout
in /etc/rcX.d
where X is your run-level (result of who -r
).
finaly
Be aware that unexpected shutdown (power outage, disk I/O freezing) will leave no trace in log file.
first
echo $(date) >> $HOME/logout.log
can be replace by
date >> $HOME/logout.log
next,
.bash_logout
is run when you disconnect, not when there is a reboot.
A reboot is when you restart host, effectively killing (more or less nicely) all it process, database, webserver and so on.
A logout is when you (or any user) disconnect from interactive session, the host stay up, as well as database and the like.
If you want script to be executed during a schedule shutdown, place then in /etc/init.d
, then have a link like K01-trace-logout
in /etc/rcX.d
where X is your run-level (result of who -r
).
finaly
Be aware that unexpected shutdown (power outage, disk I/O freezing) will leave no trace in log file.
answered Jan 31 at 13:46
Archemar
19k93366
19k93366
I have a question, would$HOME
in this case be/root
or would it be the the home directory of the user who initiates the reboot, assuming the script is in/etc/rc6.d
.
â Hunter.S.Thompson
Jan 31 at 14:03
@Hunter.S.Thompson No, unless you have way to trap which user start shutdown (by way of sudo for instance)...
â Archemar
Jan 31 at 14:06
add a comment |Â
I have a question, would$HOME
in this case be/root
or would it be the the home directory of the user who initiates the reboot, assuming the script is in/etc/rc6.d
.
â Hunter.S.Thompson
Jan 31 at 14:03
@Hunter.S.Thompson No, unless you have way to trap which user start shutdown (by way of sudo for instance)...
â Archemar
Jan 31 at 14:06
I have a question, would
$HOME
in this case be /root
or would it be the the home directory of the user who initiates the reboot, assuming the script is in /etc/rc6.d
.â Hunter.S.Thompson
Jan 31 at 14:03
I have a question, would
$HOME
in this case be /root
or would it be the the home directory of the user who initiates the reboot, assuming the script is in /etc/rc6.d
.â Hunter.S.Thompson
Jan 31 at 14:03
@Hunter.S.Thompson No, unless you have way to trap which user start shutdown (by way of sudo for instance)...
â Archemar
Jan 31 at 14:06
@Hunter.S.Thompson No, unless you have way to trap which user start shutdown (by way of sudo for instance)...
â Archemar
Jan 31 at 14:06
add a comment |Â
up vote
1
down vote
You need to run bash as login shell. You need to login as the user and when you log-out from the interactive login shell - the .bash_logout script will be executed.
Command in .bash_logout execute in login shell ,most of time i'm in non-login shell (graphic mode).
â scrapy
Jan 31 at 14:06
add a comment |Â
up vote
1
down vote
You need to run bash as login shell. You need to login as the user and when you log-out from the interactive login shell - the .bash_logout script will be executed.
Command in .bash_logout execute in login shell ,most of time i'm in non-login shell (graphic mode).
â scrapy
Jan 31 at 14:06
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You need to run bash as login shell. You need to login as the user and when you log-out from the interactive login shell - the .bash_logout script will be executed.
You need to run bash as login shell. You need to login as the user and when you log-out from the interactive login shell - the .bash_logout script will be executed.
answered Jan 31 at 13:42
Georgi Tsvetanov Tsenov
1315
1315
Command in .bash_logout execute in login shell ,most of time i'm in non-login shell (graphic mode).
â scrapy
Jan 31 at 14:06
add a comment |Â
Command in .bash_logout execute in login shell ,most of time i'm in non-login shell (graphic mode).
â scrapy
Jan 31 at 14:06
Command in .bash_logout execute in login shell ,most of time i'm in non-login shell (graphic mode).
â scrapy
Jan 31 at 14:06
Command in .bash_logout execute in login shell ,most of time i'm in non-login shell (graphic mode).
â scrapy
Jan 31 at 14:06
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420951%2fwhy-the-command-in-bash-logout-cant-run-after-reboot%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You need to be logged in to a user, then when you logout this file gets executed. Hence the name
bash_logout
. Can you specify exactly when you wantecho $(date)
to be executed? Also you can just dodate >> $HOME/logout.log
â Hunter.S.Thompson
Jan 31 at 13:30
At reboot to write time info into $HOME/logout.log.
â scrapy
Jan 31 at 13:35
date >> $HOME/logout.log
is enough.â Tomasz
Jan 31 at 13:42