Gleaning is increasingly attracting the attention of food safety networks, including food banks, as a valuable tool that simultaneously reduces food loss and alleviates food insecurity. However, managing gleaning operations can be challenging because the arrival of gleaning opportunities and the attendance of gleaner volunteers are both stochastic. We develop a stochastic optimization model to characterize and optimize a gleaning operation. The food bank chooses the gleaning schedule, which affects the gleaner capacity and the number of gleaning opportunities scheduled. In a specific field study of the Food Bank of the Southern Tier in New York, we analyze the tradeoff between call and volume service levels to find the optimum schedule that maximizes the expected total volume gleaned. Moreover, we find that increasing the gleaning window and increasing slot availability can be used as substitute mechanisms for increasing the total volume gleaned. Additionally, we use our model to assess the impact of recruiting more volunteer gleaners.