Grid technology is an emerging technology developed in the mode of computer network computing. This technology has many characteristics such as distribution, sharing, and polymorphism. In the grid environment, due to the high-performance computing of the grid, the task scheduling process becomes efficient, but it also has the problem of complex grid resource management and scheduling strategies, resulting in huge energy consumption. In order to solve the problem of energy consumption, an energy optimization model based on time constraints and energy constraints is proposed in this paper, grid resource scheduling is carried out through heuristic scheduling algorithm, and energy optimization simulation experiments are carried out under the condition of changing the number of resources and tasks. The results show that, The resource execution time corresponding to a single grid task is short, and the energy consumption value is also small. In the simulation experiment of multiple grid tasks, as the number of grid tasks increases, the task execution time increases, and the adjustment factor is 0.5 , that is, when the ratio of the time consumption factor and the energy consumption factor in the resource scheduling optimization cost function is the same, the fluctuation of the energy consumption rate is relatively stable.