After cooking sauerkraut and when kept in the refrigerator sealed up the sauerkraut will last up to 6 months in the refrigerator.
So keep the sauerkraut refrigerated and sealed to make the sauerkraut last up to 6 months.
Sauerkraut really isn't cooked but instead fermented and as long as you keep the container tightly sealed after every use and refrigerate the sauerkraut it will last for 6 months and sometimes longer.
When the sauerkraut is going bad it will begin to grow mold and have a very bad smell to it which means it should be thrown out.
I've kept homemade fermented sauerkraut in the refrigerator for 7 months before but I've never kept it any longer than that because I eat it usually before 6 or 7 months.
But I'm sure the sauerkraut would last longer than that if kept sealed and refrigerated.