0

My system regularly moves /tmp to /snapshot. (background)

Now I want to create a cronjob that checks every minute if the directory was renamed by the system, and renames it back.

$ sudo crontab -l
# ...
*/1 * * * * if [ ! -d "/tmp" ];        then mv /snapshot.0         /tmp;       2>> /home/t/tmp.err1; date >> /home/t/tmp.log1; fi 
*/1 * * * * if [ ! -d "/a" ];          then mv /b                  /a          2>> /home/t/tmp.err2; date >> /home/t/tmp.log2; fi 
*/1 * * * * if [ ! -d "/home/t/tmp" ]; then mv /home/t/snapshot.0  /home/t/tmp 2>> /home/t/tmp.err3; date >> /home/t/tmp.log3; fi 
*/1 * * * * echo "test" #this command definitely doesn't depend on /tmp

These work as long as /tmp exists. However when /tmp gets renamed they all fail with this entry in /var/log/cron.log

{date and time} ttp CRON[{job-id}]: (CRON) error (create tmpfile)

Why does sudo crontab depend on /tmp? Is there a way around it?

4
  • "My system regularly moves /tmp to /snapshot" this is not normal behaviour. I would class this as a critical fault. What utility have you installed or written that does this?
    – roaima
    Jun 29, 2020 at 13:16
  • @roaima I wish I knew! Please refer to the linked post at the beginning for why it might have happened.
    – user2740
    Jun 29, 2020 at 18:03
  • I looked at the linked post and although you've asked much the same question there you haven't really got a concrete answer as to why it happens.
    – roaima
    Jun 29, 2020 at 18:14
  • @roaima That is correct, I don't have an answer to that. I intended to find the root cause with the linked post, but haven't so far. I do not remember installing any utilities that might have caused this, I certainly never intended for this to happen.
    – user2740
    Jun 29, 2020 at 18:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.