# Lock files building up in /var/webmin/locks/

**URL:** <https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859>\
**Category:** Webmin\
**Created:** [October 16, 2024, 8:51pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859 "2024-10-16T20:51:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert.minor](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@robert.minor](https://forum.virtualmin.com/u/robert.minor)\
**Post date:** [October 16, 2024, 8:51pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/1 "2024-10-16T20:51:10Z")

</div>

| SYSTEM INFORMATION | |
| --- | --- |
| OS type and version | Debian 12 |
| Webmin version | 2.202 |

I am getting lock files in the /var/webmin/locks/####/ folder. Eventually I started getting inode issues with too many of these files in the /var directory. I deleted them and noticed they reappeared. I am not sure why I am getting these continually without any cleanup. I have 2 nearly identical Debian 12 servers that are both getting these. Any ideas, I have done google searches and it doesn’t turn up much in this regard.

lrwxrwxrwx 1 root root 66 Oct 16 15:30 1729110651-3895 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:31 1729110677-3896 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:31 1729110703-3897 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:32 1729110729-3898 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:32 1729110756-3899 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:33 1729110782-3900 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:33 1729110808-3901 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:33 1729110834-3902 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:34 1729110860-3903 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:34 1729110886-3904 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:35 1729110912-3905 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:35 1729110938-3906 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:36 1729110964-3907 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:36 1729110990-3908 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:36 1729111017-3909 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:37 1729111043-3910 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:37 1729111069-3911 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:38 1729111095-3912 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:38 1729111121-3913 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:39 1729111147-3914 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:39 1729111173-3915 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:39 1729111199-3916 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:40 1729111225-3917 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:40 1729111251-3918 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:41 1729111277-3919 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:41 1729111303-3920 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:42 1729111330-3921 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock  
lrwxrwxrwx 1 root root 66 Oct 16 15:42 1729111356-3922 → /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock

---

<div class="post-metadata">

**Author:** ![jimdunn](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimdunn/32/3487_2.png) [@jimdunn](https://forum.virtualmin.com/u/jimdunn)\
**Post date:** [October 18, 2024, 3:59am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/2 "2024-10-18T03:59:06Z")

</div>

I have a Debian 11 server and have found the same thing… over 48,000+ links in the /var/webmin/locks/446415 folder. I don’t see any inode issues yet, but I hope support can find a way to clean up this folder. They are dated from Oct 3 - 17.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [October 18, 2024, 4:07am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/3 "2024-10-18T04:07:00Z")

</div>

Yeah, I can reproduce this, too.

@Ilia realtime monitoring is leaking lock links.

```auto
ls -l 1729076390-62842
lrwxrwxrwx 1 root root 66 Oct 16 10:59 1729076390-62842 -> /var/webmin/modules/authentic-theme/real-time-monitoring.json.lock

```

That file doesn’t exist, but the link remains. Also, why is this a link?

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 18, 2024, 10:00am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/4 "2024-10-18T10:00:46Z")

</div>

> [@Joe](#):
>
> Yeah, I can reproduce this, too.

Well, initially, I came up with a custom file locking feature specific to the stats server.

> [@Joe](#):
>
> That file doesn’t exist, but the link remains. Also, why is this a link?

However, @Jamie insisted on using the Webmin inbuilt `lock_file` function.

The reason why those locks are left around and even appear when `forcefile` flag is used for `lock_file` is unclear to me at the moment. Perhaps because the default `lock_file` functions wasn’t meant for endlessly running process…?

> [@Joe](#):
>
> @Ilia realtime monitoring is leaking lock links.

Jamie, could you shed light on it? Should I perhaps revert to using my custom locking function? Alternatively, we might not need locking at all, since there’s only one process on the system that writes to that file. It’s sub-optimal, but it would resolve some ongoing locking issues.

---

<div class="post-metadata">

**Author:** ![Jamie](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jamie/32/8589_2.png) [@Jamie](https://forum.virtualmin.com/u/Jamie)\
**Post date:** [October 18, 2024, 10:34pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/5 "2024-10-18T22:34:38Z")

</div>

> [@Ilia](#):
>
> Jamie, could you shed light on it? Should I perhaps revert to using my custom locking function? Alternatively, we might not need locking at all, since there’s only one process on the system that writes to that file. It’s sub-optimal, but it would resolve some ongoing locking issues.

Those files are created so that it’s possible to find all the open locks Webmin has. However, they should get cleaned up automatically when the lock on the destination file is released … but due to a bug they don’t always ☹

That’s fixed in this patch though : [Make sure temporary lock link files are deleted https://forum.virtual… · webmin/webmin@4ef76b2 · GitHub](https://github.com/webmin/webmin/commit/4ef76b2ed9cc2eb7ddc8b50a21d4eda5f9b7803a)

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 18, 2024, 10:36pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/6 "2024-10-18T22:36:24Z")

</div>

Thanks, Jamie! I will give it a try!

---

<div class="post-metadata">

**Author:** ![jimdunn](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimdunn/32/3487_2.png) [@jimdunn](https://forum.virtualmin.com/u/jimdunn)\
**Post date:** [October 19, 2024, 7:33am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/7 "2024-10-19T07:33:40Z")

</div>

I added this to /etc/cron.daily, but I should’ve asked “how many days of locks should be kept”…

```auto
#!/bin/sh

locks=/var/webmin/locks

if test -d $locks; then
  /usr/bin/find $locks -ctime +2 -delete > /dev/null
fi

```

---

<div class="post-metadata">

**Author:** ![robert.minor](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@robert.minor](https://forum.virtualmin.com/u/robert.minor)\
**Post date:** [October 19, 2024, 5:10pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/8 "2024-10-19T17:10:53Z")

</div>

Since this is verified, a fix will get pushed to an update in the near future? I

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 19, 2024, 7:37pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/9 "2024-10-19T19:37:17Z")

</div>

> [@Jamie](#):
>
> Those files are created so that it’s possible to find all the open locks Webmin has. However, they should get cleaned up automatically when the lock on the destination file is released

@Jamie, thanks for fixing that bug!

Nevertheless, it didn’t change anything regarding the original problem, where locking is performed from the server. I’m curious… Why would you expect it to work for a process that never finishes? Specifically, I’m referring to this line `push(@main::temporary_files, $locklink);` of code.

Perhaps I shouldn’t relock the file every time and instead do it just once. This might work, but I don’t think it’s the right solution — it’s more of a workaround. Like what if the stats server gets killed?

---

<div class="post-metadata">

**Author:** ![Jamie](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jamie/32/8589_2.png) [@Jamie](https://forum.virtualmin.com/u/Jamie)\
**Post date:** [October 19, 2024, 11:04pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/10 "2024-10-19T23:04:38Z")

</div>

Maybe the server should lock the file just before writing to it, and unlock afterwards?

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 19, 2024, 11:18pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/11 "2024-10-19T23:18:35Z")

</div>

I think this is _exactly_ what we do currently.

---

<div class="post-metadata">

**Author:** ![Jamie](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jamie/32/8589_2.png) [@Jamie](https://forum.virtualmin.com/u/Jamie)\
**Post date:** [October 20, 2024, 12:35am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/12 "2024-10-20T00:35:38Z")

</div>

Can you link to the code?

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 20, 2024, 1:12am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/13 "2024-10-20T01:12:28Z")

</div>

Yes, sure! Please have a look:

> <https://github.com/webmin/authentic-theme/blob/150d475c09d6c01f446af5fd974311429bab68e1/stats-lib-funcs.pl#L274>

---

<div class="post-metadata">

**Author:** ![Jamie](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jamie/32/8589_2.png) [@Jamie](https://forum.virtualmin.com/u/Jamie)\
**Post date:** [October 20, 2024, 2:42am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/14 "2024-10-20T02:42:24Z")

</div>

That actually looks fine … however I found another webmin bug where those lock links aren’t removed on unlock. Fixed here : [Clean up lock link on unlock https://forum.virtualmin.com/t/lock-file… · webmin/webmin@c1196f7 · GitHub](https://github.com/webmin/webmin/commit/c1196f744a51d41c9d7a2e45658fdbafd2007e74)

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 20, 2024, 8:45am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/15 "2024-10-20T08:45:57Z")

</div>

Thanks, @Jamie. I see a bug in this new code, though. You’re adding the _lock file_ to `%locked_file_link` in `lock_file`, but in `unlock_file`, you’re trying to clean it up using the _real file_ instead. It won’t work.

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 20, 2024, 1:25pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/16 "2024-10-20T13:25:53Z")

</div>

Furthermore, perhaps related:

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/3X/9/b/9bb32a3ae9f26a882d785734f661e06ce0470456.png)

---

<div class="post-metadata">

**Author:** ![Jamie](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jamie/32/8589_2.png) [@Jamie](https://forum.virtualmin.com/u/Jamie)\
**Post date:** [October 21, 2024, 1:05am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/17 "2024-10-21T01:05:36Z")

</div>

Ok I checked in a further fix for this.

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 21, 2024, 8:50am UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/18 "2024-10-21T08:50:10Z")

</div>

Thanks, @Jamie! It seems to be working now. Should we also clean up the PID-related directories in `/var/webmin/locks` since those are accumulating too? Maybe we could just use `rmdir` for that?

---

<div class="post-metadata">

**Author:** ![Jamie](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jamie/32/8589_2.png) [@Jamie](https://forum.virtualmin.com/u/Jamie)\
**Post date:** [October 21, 2024, 11:30pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/19 "2024-10-21T23:30:12Z")

</div>

Good idea, I’ll also add code for that. Not sure how I missed all these cleanups when I initially implemented this feature…

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [October 22, 2024, 1:00pm UTC](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859/20 "2024-10-22T13:00:32Z")

</div>

Excellent! Thanks, Jamie!

[Next page](https://forum.virtualmin.com/t/lock-files-building-up-in-var-webmin-locks/129859.md?page=2)
