In this paper the optimal management of an aggregated dynamic pension fund is studied. To cover the promised liabilities to workers at the age of retirement, the plan sponsor continuously manages time-varying funds. He or she can choose the rate of contribution to the fund, the investment in a given number of risky assets, and a security with constant rate of return. The problem of maximizing the probability that the fund assets achieve some prescribed goal before some undesirable lower value, or ruin point, is first considered. Secondly, the problem of minimizing (resp. maximizing) the expected discounted cost of reaching a ruin point (resp. beating a desired objective) is solved. Finally, maximization of utility function when the fund can suddenly terminate is analyzed. The main finding is that optimal investment policies are of constant proportionality type.