zlacker

[return to "Postgres Postmaster does not scale"]
1. kayson+p82[view] [source] 2026-02-05 05:41:27
>>davidg+(OP)
> sudo echo $NUM_PAGES > /proc/sys/vm/nr_hugepages

This won't work :) echo will run as root but the redirection is still running as the unprivileged user. Needs to be run from a privileged shell or by doing something like sudo sh -c "echo $NUM_PAGES > /proc/sys/vm/nr_hugepages"

The point gets across, though, technicality notwithstanding.

◧◩
2. thayne+392[view] [source] 2026-02-05 05:49:11
>>kayson+p82
Or

    echo $NUM_PAGES | sudo tee /proc/sys/vm/nr_hugepages 

I've always found it odd that there isn't a standard command to write stdin to a file that doesn't also write it to stdout. Or that tee doesn't have an option to supress writing to stdout.
◧◩◪
3. TheDon+wA2[view] [source] 2026-02-05 09:53:40
>>thayne+392
> I've always found it odd that there isn't a standard command to write stdin to a file that doesn't also write it to stdout

If you happen to have moreutils installed, you can do that with pee

    echo $NUM_PAGES | sudo pee 'cat > /proc/sys/vm/nr_hugepages'
◧◩◪◨
4. direwo+eM2[view] [source] 2026-02-05 11:37:18
>>TheDon+wA2
why not write sh -c then?
◧◩◪◨⬒
5. TheDon+jS2[view] [source] 2026-02-05 12:33:58
>>direwo+eM2
Because 'sh' isn't in moreutils and is harder to remember, next question.

Why use something portable when you can use cat pee?

[go to top]