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?