Effective task scheduling has become the key to optimizing resource allocation, reducing operation costs, and enhancing the user experience. The complexity and dynamics of cloud computing environments require task scheduling algorithms that can flexibly respond to multiple computing demands and changing resource states. Therefore, we propose an enhanced Red-tailed Hawk algorithm (named ERTH) based on multiple elite policies and chaotic mapping, while applying this approach in conjunction with the proposed scheduling model to optimize the efficiency of task scheduling in cloud computing environments. We apply the ERTH algorithm to a real cloud computing environment and conduct a comparison with the original RTH and other conventional algorithms. The proposed ERTH algorithm has better convergence speed and stability in most cases of small and large-scale tasks and performs better in minimizing the task completion time and system load cost. Specifically, our experiments show that the ERTH algorithm reduces the total system cost by 34.8% and 36.4% relative to the traditional algorithm for tasks of different sizes. Further, evaluations in the IEEE Congress on Evolutionary Computation (CEC) benchmark test sets show that the ERTH algorithm outperforms the traditional or emerging algorithms in several performance metrics such as mean, standard deviation, etc. The proposal and validation of the ERTH algorithm are of great significance in promoting the application of intelligent optimization algorithms in cloud computing.