This study addresses the problem of scheduling tank trucks at a fuel distribution terminal. The plant was modeled in the max-plus algebra, applying machine learning to determine process times. With this model, and based on a just-in-time approach, we have developed a predictive controller with two operation modes. This control system aims to prevent the excess of tank trucks inside the loading yard, thus achieving a better flow, efficiency, and safety in the process. Next, we have investigated the case study of a realistic and representative fuel distribution terminal, developing a simulator to enable a performance comparison between the proposed algorithms and the current heuristic. There was a 42.7% reduction in the work-in-progress (WIP) and 41.4% in the lead time, while productivity suffered a 2.8% loss. Bearing in mind, however, that there is flexibility in parametrization to mitigate this loss of productivity. In doing so, the reductions in WIP and lead time are slightly lower, at 34.7% for both metrics. The results show that the proposed control system can contribute significantly to improving the company's performance indicators. (C) 2021 Elsevier Ltd. All rights reserved.