Fog computing has changed the distributed computing rapidly by including the smart devices widely distributed at the network edges. It is able to provide less latency and is more capable of decreasing traffic jam in the network. However, it will bring more difficulties for resource managing and task scheduling especially in a decentralized ad hoc network. In this paper, we propose a method that takes advantages of the immune mechanism to schedule tasks in a decentralized way for fog computing. By using forward propagation and backward propagation in the ad hoc network, the power of distributed schedulers is used to generate the optimized scheduler strategies to deal with computing nodes overloaded and achieve the optimal task finishing time reducing. The experiment results show that our approach can beat similar methods.