0

How do I know if a file or files are in deferred state using bash? Is there a way to detect this?

sample:

when saving a file, kernel cache the file and not yet written on the disk. this is the D state or deferred state. when its deferred state, when you check the file like php -r "var_dump(file_exists($filename));", the kernel will respond, yep the file is there. but in reality, the file wasn't written on the disk yet. and when the server got restarted, the file is gone.

the event happened to us and i want to prevent it or create a monitoring tool that detects it and notify us so we can copy the files on other server before restarting it.

2

2 Answers 2

1

I think you are looking at a wrong "problem". When system is properly restarted, the shutdown process will make sure that all data is written to permanent storage.

So, the problem here is that restart is done in wrong way, which causes data loss. You need to change your restart to use shutdown -r now or similar command.

0

i think i found the tool. not perfect of what i am looking for, but i'll make it work.

its a vmtouch command, can be found at https://github.com/hoytech/vmtouch

thanks.

1
  • but if you have better solution, let me know. thanks.
    – camilox
    Dec 17, 2020 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .