Race condition? How do I stop Obsidian from overwriting changes to files caused by a shell command? #349
Replies: 1 comment 3 replies
-
Hi! Thank you for you question 🙂.
I don't know Obsidian's updates well enough to say if they may affect this or not. There has been no significant changes to SC in the past few months. When was the last time you have updated the SC plugin? What version of SC and Obsidian are you using? And if you have updated SC recently, do you remember what was the version you had before? (The earlier version can be seen if you open the plugin's installation folder and look for files named like
Hmm, modifying files with shell commands / scripts is a very common task and should be perfectly doable. I don't know why it has stopped working in your use case. But you can check the following:
The Shell commands plugin does not use this kind of signaling. I don't even know if Obsidian's API has any method so that a plugin could tell Obsidian that files have changed and should be reloaded from disk. However, there should not be any need for that kind of signaling, because Obsidian has been very good in noticing all external changes to files automatically, at least according to my personal experience. If you need further help, may I ask you to include the SC plugin's Also, to rule out some possible issues:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I have a shell script I've been using for a while now, called "smaller-images.sh", which I use to shrink the images in a file. I have it "hooked up" to a Shell Command called "Shrink Images in File" and have used it successfully for many files to resize images.
Here is the "Shrink Images in File" command:

It prompts for a new image size, calls my little script and voila! Life is a little better afterwards.
A couple days ago this was working fine.
Today it started mysteriously failing, and what I'm seeing is that while the script works properly, Obsidian does not notice the changes caused by the script, and instead overwrites them. Obsidian seems to flush the file to disk as soon as I move to another file in Obsidian's file browser, but since it doesn't know the file has changed, this is a reversion. It's like Obsidian has a cache of the file in memory and writes it out to disk whenever I move away from viewing the file in Obsidian. The grep statement at the end of the script allows me to confirm this is what happens. Also, when I quit Obsidian and run the script by hand, then launch Obsidian, the changes are there and they stick.
Thanks for any help!
Beta Was this translation helpful? Give feedback.
All reactions