I am new to drupal and waht to have weekly and monthly cron.
I found hook_cron for this which will execute when drupal cron get executed.
I found hook_cronapi also which accents parameter
'rule' => '*/2 * * *', // Run this job every day at 3am.
Want to know what id hook_cronapi and how its works.
Please help me achieving this task.
The core cron in drupal works as everytime it is executed it runs through all hook_crons and executes them.
If you want to have one cron that should execute weekly, and one monthly you can install Elysia Cron module which will let you to set different settings for every different hook_cron implementation. These settings are set either by hook_cronapi, or through Cron Settings in admin interface(which is very easy and straightforward).