For unmanned aerial vehicle (UAV) trajectory design, the total propulsion energy consumption and initial-final location constraints are practical factors to consider. However, unlike traditional offline designs, these two constraints are non-trivial to concurrently satisfy in online UAV trajectory designs for real-time target tracking, due to the undetermined information. To address this issue, we propose a novel online UAV trajectory optimization approach for the weighted sum-predicted posterior Cram\'er-Rao bound (PCRB) minimization, which guarantees the feasibility of satisfying the two mentioned constraints. Specifically, our approach designs the UAV trajectory by solving two subproblems: the candidate trajectory optimization problem and the energy-aware backup trajectory optimization problem. Then, an efficient solution to the candidate trajectory optimization problem is proposed based on Dinkelbach's transform and the Lasserre hierarchy, which achieves the global optimal solution under a given sufficient condition. The energy-aware backup trajectory optimization problem is solved by the successive convex approximation method. Numerical results show that our proposed UAV trajectory optimization approach significantly outperforms the benchmark regarding sensing performance and energy utilization flexibility.