The rapid growth of Internet of Things (IoT) applications generates vast volumes of high-speed data streams from numerous devices. Cloud computing solutions often handle and manage this data; however, for certain applications, the latency introduced by transmitting data from edge devices to the cloud may be unacceptable. This issue is exacerbated by the bandwidth constraints of public networks, which become significant barriers in large-scale IoT implementations. Consequently, effective resource management, service management, data storage, and power management require more robust infrastructure and complex protocols. An "intelligent gateway" based on fog computing can enhance the efficient utilization of cloud and network resources. Resource planning and management in a fog-cloud environment significantly impact system performance, particularly latency. This problem is known to be NP-hard. This paper addresses the challenge of lifetime optimization for scheduling data-intensive tasks in fog and cloud-based IoT systems. Initially, we propose an Integer Linear Programming (ILP) optimization model to frame the problem. Subsequently, we introduce a heuristic method named Data-Locality Aware Job Scheduling in Fog-Cloud (DLSFC), which is derived from the proposed formulation. The effectiveness of DLSFC is evaluated across various system characteristics, with results demonstrating that DLSFC achieves solutions within 85 % of the ideal outcome provided by the LP solver.