With the continuous growth of Industry 4.0 (I4.0), the industrial sector has transformed into smart factories, enhancing business competitiveness while aiming for the sustainable development of organizations. Machinery is a critical component and key to the success of production in a smart industrial factory. Minimizing unplanned downtime (UPDT) poses a significant challenge in designing an effective maintenance system. In the era of Industry 4.0, the most widely adopted maintenance frameworks are intelligent maintenance systems (IMSs), which integrate predictive maintenance with computerized systems. IMSs are intelligent tools designed to efficiently plan maintenance cycles for each machine component in a smart factory. This research presents the application of a search algorithm named state space search (SSS) in conjunction with a newly designed IMS, aimed at optimizing maintenance routines by identifying the optimal timing for maintenance cycles. The design began with the development of a new IMS concept that incorporates three key elements: the automation pyramid standard, Industrial Internet of Things (IIoT) sensors, and a computerized maintenance management system (CMMS). The CMMS collects machine data from the maintenance database, while real-time parameters are gathered via IIoT sensors from the supervisory control and data acquisition (SCADA) system. The new IMS concept provides a summary of the total maintenance cost and the remaining lifetime of the equipment. By integrating with SSS algorithms, the IMS presents optimized maintenance cycle solutions to the maintenance manager, focusing on minimizing costs while maximizing the remaining lifetime of the equipment. Moreover, the SSS algorithms take into account the risks associated with maintenance routines, following factory standards such as failure mode and effects analysis (FMEA). This approach is well suited to smart factories and helps to reduce UPDT.