I have a very weird problem that I might not have cooked down correctly, but I tried a minimal example:
In a 20.04 lxd container on 20.04, I am trying to run a job triggered by incron. For my minimal example, this is my incron line:
/home/scanfiler/test IN_CLOSE_WRITE /home/scanfiler/test.sh &>> /tmp/log-scanfiler-test
This is my test script
#!/bin/bash
logger "Starting"
touch /tmp/test/test-$(date +%s)-1
touch ~/test_out/test-$(date +%s)-1
sleep 20
touch /tmp/test/test-$(date +%s)-2
touch ~/test_out/test-$(date +%s)-2
logger "Done"
I am writing to the log, then I am creating one file in the home folder and one in the tmp folder, then I am waiting 20 seconds (this to give me time to check DURING runtime, in case tmp is somehow immediately cleared), then I am writing to more files.
This is what happens:
scanfiler ~scanfiler # rm test/testblah && touch test/testblah
scanfiler ~scanfiler # journalctl -xe|tail
Aug 17 14:59:26 scanfiler incrond[2526]: PATH (/home/scanfiler/test) FILE (testblah) EVENT (IN_CLOSE_WRITE)
Aug 17 14:59:26 scanfiler incrond[2526]: (scanfiler) CMD (/home/scanfiler/test.sh &>> /tmp/log-scanfiler-test)
Aug 17 14:59:26 scanfiler scanfiler[1250558]: Starting
scanfiler ~scanfiler #
scanfiler ~scanfiler # ls /tmp/test
scanfiler ~scanfiler # ls test_out
test-1597669166-1
scanfiler ~scanfiler # journalctl -xe|tail
Aug 17 14:59:26 scanfiler incrond[2526]: PATH (/home/scanfiler/test) FILE (testblah) EVENT (IN_CLOSE_WRITE)
Aug 17 14:59:26 scanfiler incrond[2526]: (scanfiler) CMD (/home/scanfiler/test.sh &>> /tmp/log-scanfiler-test)
Aug 17 14:59:26 scanfiler scanfiler[1250558]: Starting
scanfiler ~scanfiler # journalctl -xe|tail
Aug 17 14:59:26 scanfiler incrond[2526]: PATH (/home/scanfiler/test) FILE (testblah) EVENT (IN_CLOSE_WRITE)
Aug 17 14:59:26 scanfiler incrond[2526]: (scanfiler) CMD (/home/scanfiler/test.sh &>> /tmp/log-scanfiler-test)
Aug 17 14:59:26 scanfiler scanfiler[1250558]: Starting
Aug 17 14:59:46 scanfiler scanfiler[1250627]: Done
scanfiler ~scanfiler # ls /tmp/test
scanfiler ~scanfiler # ls test_out
test-1597669166-1 test-1597669186-2
scanfiler ~scanfiler # ls /tmp/log-scanfiler-test
ls: cannot access '/tmp/log-scanfiler-test': No such file or directory
As you can see, even during runtime, the tmp file is NOT created, while the one in the home directory is there. Eventually, not even the log file that is supposed to be in tmp is there. When run by the same user in console, everything works fine, so my tmp permissions are probably not somehow broken.
Can anybody give me a clue what is happening here? I have more weird issues in my scripts (which runs fine when run in console), but maybe they are related, so I would like to solve this first.