The main goal of any task scheduling problem is to map several tasks to proper processors so that it could optimize one or more objectives at an acceptable time under some constraints. In this paper, the problem of scheduling n independent work with different due times on Two -Machines in the sequential flow shop environment is investigated. To solve this problem, we propose a hybrid metaheuristic algorithm that combines the Simulated Annealing (SA) with Gravitational Search Algorithm (GSA) called SA_GSA. The proposed hybrid algorithm starts the above problem by defining two stages. First, we generate an initial solution of the problem using the SA algorithm, then we run the GSA algorithm on the generated solution. To evaluate the answers, the criterion of the minimum weight of delays and delays of tasks has been used as an objective function, which is considered in line with the goals of timely production systems. The proposed algorithm is presented in 4 scenarios, which are obtained by considering two different modes for the Markov chain and how to reduce the temperature. Finally, according to the analysis of the results and the quality of the results, the best scenario is introduced as the final result. Experimental results show that the performance of the proposed algorithm in finding the optimal answers in most of the problems could compete with state-of-the-art.