Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 16:22:19 +01:00
Log /etc/rc.local std{out,err}

Let us not add tail -c +2 to be precise, despite being less clean in this case.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 16:11:26 +01:00
Log /etc/rc.local std{out,err}
/etc/rc.local:
#!/bin/sh

SCRIPT='/etc/rc.local'
FOLDER_NAME=etc_rc_local
su --login benjamin_loison -c "
    mkdir $FOLDER_NAME/
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 15:51:00 +01:00
Log /etc/rc.local std{out,err}

Tested on Debian 12 GNOME.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 15:46:54 +01:00
Log /etc/rc.local std{out,err}
/etc/rc.local:
#!/bin/sh

SCRIPT='/etc/rc.local'
FOLDER_NAME=etc_rc_local
su --login benjamin_loison -c "
    mkdir $FOLDER_NAME/
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 15:40:46 +01:00
Log /etc/rc.local std{out,err}
head -n 5 etc_rc_local/std{out,err}.txt
Output:
==> etc_rc_local/stdout.txt <==
Start of /etc/rc.local at Tue Feb 18 03:38:16 PM CET 2025
Tue…
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 15:37:05 +01:00
Log /etc/rc.local std{out,err}
Shell:
while [ true ]
do
    echo hey
    sleep 1
done >> log.txt &
[1] 95309

log.txt correctly get filled.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 15:36:22 +01:00
Log /etc/rc.local std{out,err}
Shell:
while [ true ]
do
    echo hey
    sleep 1
done &
[1] 95150
benjamin_loison@Benjamin-Loison-HP-Debian:~$ hey
hey
hey
hey
^C
benjamin_loison@B…
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 15:34:31 +01:00
Log /etc/rc.local std{out,err}

while [ true ] makes the boot stuck.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:49:28 +01:00
Log /etc/rc.local std{out,err}
#!/bin/sh

SCRIPT='/etc/rc.local'
FOLDER_NAME=etc_rc_local
su --login benjamin_loison -c "
    mkdir $FOLDER_NAME/
    cd $FOLDER_NAME/
    (
        echo \"Start of $SCRIPT at…
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:37:58 +01:00
Log /etc/rc.local std{out,err}
cd /root/

works as wanted.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:34:30 +01:00
Log /etc/rc.local std{out,err}
ls /etc/
Output:
adduser.conf		cups		     group	      libpaper.d      NetworkManager  rc5.d		 sudoers.d
adjtime			cupshelpers	     group-	    …
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:33:41 +01:00
Log /etc/rc.local std{out,err}
mktemp --suffix _etc_rc_local_stdout
/tmp/tmp.hdUio8goPt_etc_rc_local_stdout

However, permanent with date logs would be nice.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:29:06 +01:00
Log /etc/rc.local std{out,err}
sudo find / -name 'my_stdout.txt' 2> /dev/null
/my_stdout.txt
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:27:42 +01:00
Log /etc/rc.local std{out,err}
sudo chmod +x /etc/rc.local
ls -l /etc/rc.local
-rwxr-xr-x 1 root root 134 Feb 18 14:22 /etc/rc.local
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:26:43 +01:00
Log /etc/rc.local std{out,err}

I have:

ls -l /etc/rc.local
-rw-r--r-- 1 root root 134 Feb 18 14:22 /etc/rc.local
Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:25:49 +01:00
Log /etc/rc.local std{out,err}

Well it is not, so maybe the permissions are to blame.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:23:59 +01:00
Log /etc/rc.local std{out,err}

Let us add:

while [ true ]
do
    sleep 1
done

to see if it stays stuck.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:21:24 +01:00
Log /etc/rc.local std{out,err}
sudo find / -name 'my_stdout.txt' 2> /dev/null

does not return anything on reboot.

Benjamin_Loison commented on issue Benjamin_Loison/linux#66 2025-02-18 14:18:39 +01:00
Log /etc/rc.local std{out,err}
/etc/rc.local:
#!/bin/sh

(echo my_stdout_content && echo my_stderr_content >&2)
Benjamin_Loison opened issue Benjamin_Loison/linux#66 2025-02-18 14:16:42 +01:00
Log /etc/rc.local std{out,err}