![]() |
How to automatically run a script when SD is mounted?
Hi all,
In order to find the cause of reboot loops I installed syslogkd. I can let it write logs to one of the SD cards. But after rebooting no new logs are written to it. I guess this is because the daemon tries to write the files before the SD card is mounted. So my next idea was to automatically copy the logfiles from /var/log/ to the SD card as soon as it is mounted. But it won't work so far. To test using udev for this I have made these files: /etc/udev/rules.d/91_backupsyslogs.rules : Code:
KERNEL=="mmc1", RUN+="/usr/local/bin/backup_syslogs.sh" Code:
#!/bin/sh |
Re: How to automatically run a script when SD is mounted?
To answer the topic question:
If the card is a vfat card, edit /usr/sbin/mmc-mount and put "exec /usr/local/bin/backup_syslogs.sh" at the end. If it's an ext* one, edit /usr/sbin/osso-mmc-mount.sh and find the right section depending on fs to shove that line in. |
Re: How to automatically run a script when SD is mounted?
Quote:
|
Re: How to automatically run a script when SD is mounted?
Quote:
|
Re: How to automatically run a script when SD is mounted?
Quote:
|
Re: How to automatically run a script when SD is mounted?
Quote:
|
Re: How to automatically run a script when SD is mounted?
Calling my script from '/usr/sbin/mmc-mount' with 'exec' caused 'memory card corrupted or unformatted' error popups. Without 'exec' and with the output suppressed it works:
Code:
sh /usr/local/bin/backup_syslogs.sh &> /dev/null |
Re: How to automatically run a script when SD is mounted?
You definitely don't want the 'exec' there.. it replaces the process (the original script) with the one you're calling, which isn't what you want to do - you just want to call that backup_syslogs.sh script and then go on with the original script (even if that's just to exit, if you placed that call at the end).
Just Code:
/usr/local/bin/backup_syslogs.sh &> /dev/null Code:
#!/bin/sh |
All times are GMT. The time now is 06:42. |
vBulletin® Version 3.8.8