An important issue of the spectrum sensing functionality in Cognitive Radio (CR) networks is the ability of tuning the parameters according to the time, i.g., the capacity of the Cognitive Radio Users in the network and the transmission time, which become more challenging in presence of Primary User (PU) mobility. In this paper, an optimal spectrum sensing is depicted to achieve the feature: I)to determine the value of the capacity of the Cognitive Radio Users in the network; II) to determine the optimal transmission time of each CR user. First, closed-form expressions for the capacity of the Cognitive Radio users and the optimal transmission time of each CR user are derived for a general PU mobility model. Then, the expressions are applied to a widely used model, i.e., the Random Walk mobility model. Finally, the analytical results are verified through simulations.