Script to periodically update assumevalid block in bitcoin core configuration, good idea? On my server my full node Bitcoin Core 0.15.1 can take several minutes, on starting, to "validate blocks".  And during that time it's thrashing the disk, slowing down everything else.

So I discovered the assumevalid command line/configuration parameter which takes a block hash and tells Core to "assume valid" that block and all ancestors.  Apparently it's updated when Bitcoin Core releases - and as a result it can be weeks or even months old.

So I created a little script to RPC to my full node and do GetBlockCount to get the current height, then I subtract 400 and use GetBlockHash to get the hash for a block about 3 days back.  Then I rewrite bitcoin.conf with that value as the parameter of assumevalid.

So sure enough Bitcoin Core seems to start faster after doing that.

Is it a good idea?  Or more specifically, what could go wrong?
So sure enough Bitcoin Core seems to start faster after doing that.
Is it a good idea? Or more specifically, what could go wrong?

It must be the placebo effect that you are experiencing because assumevalid has no effect on this when the default values for the consistency checks are used (changed with parameters -checklevel and -checkblocks)
There isn't anything that could go wrong, but it also isn't actually doing anything. There are two reasons for this: the default depth to check for is 6 blocks and the default check level is 3 which means that the part that uses assumevalid is not even run.
Now if you increased the check depth to be more than 400 blocks and the check level to be 4, then yes, you should see a difference. But with the default parameters, it won't make a different.
Setting assumevalid is really only useful for the initial sync and for when you are catching up from being a few weeks behind. But that all happens once the software has fully started, not during the initialization phase which you are asking about.