Cron and atd jobs cant see manually mounted file systems

If none of the more specific forums is the right place to ask

Cron and atd jobs cant see manually mounted file systems

Postby couling » 2018-02-11 16:54

This has really got me scratching my head so apologies for cross posting the question.

On my raspberry pi, I recently upgraded to debian [/raspbian] buster. Ever since then, cron jobs creating directories using
Code: Select all
mkdir -p <directory name>
will create the directory on the root file system / device instead of the mounted device /backup/. This seems to only apply to manually mounted file systems, not drives listed in /etc/fstab.

I'm absolutely certain that /backup on /dev/sda2 (aka "/") is empty. I'm pretty certain that I'm mounting my USB drive correctly (mount /dev/disk/by-label/BACKUP1 /backup)

Does anyone have any idea what is going on here?




Steps to Reproduce


As root:

Code: Select all
    # mkdir /backup
    # mount /dev/sdb1 /backup
    # mkdir -p /backup/mars/foo
    # batch << EOF
    # mkdir -p /backup/mars/bar
    > ls /backup/mars > /tmp/mount.test.log
    > EOF


Wait for the script to end.

Expected


Code: Select all
    # ls /backup/mars
    foo bar
    # cat /tmp/mount.test.log
    foo bar
    # umount /backup
    # ls /backup/mars
    ls: cannot access '/backup/mars': No such file or directory


Actual Behaviour

Code: Select all
    # ls /backup/mars
    foo
    # cat /tmp/mount.test.log
    bar
    # umount /backup
    # ls /backup/mars
    bar
couling
 
Posts: 17
Joined: 2010-07-11 10:55

Re: Cron and atd jobs cant see manually mounted file systems

Postby couling » 2018-02-12 01:01

Update... I've also discovered that running `mount > /tmp/mount.test.log 2>&1` as a cron job is also missing the the file system I mounted.
couling
 
Posts: 17
Joined: 2010-07-11 10:55

Re: Cron and atd jobs cant see manually mounted file systems

Postby couling » 2018-02-12 14:12

More info. Looks like this is being caused by the two processes (crond and sshd) being in separate namespaces for mount (/proc/[pid]/ns/mnt has a different pointer for each).

If anyone knows why, or better how to stop it happening, that would be great.
couling
 
Posts: 17
Joined: 2010-07-11 10:55


Return to General Questions

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable