adding timeout to cron lock file

fixes https://github.com/owncloud/core/issues/3221

This PR leaves the cron code almost untouched to allow backporting - if required/requested.

Overall the cron code needs refactoring to allow unit testing and proper code structure.

@PVince81 @MorrisJobke @Raydiation please review

@karlitschek @craigpg @MTRichards for your information
Depending on from where the cronjob is called (in case of ajax for instance) id lock the file by passing a third parameter: LOCK_EX