Perform task on opening the site I'm new to writing modules.

I would like my custom module to perform a task whenever the main page is loaded and no user is logged in, like when a user enters the url to my page, then the page loads and does something. I searched for a while now, but can't find the hook for this

What i tried was this:

function mymod_menu() {
  $items = array();

  $items['/'] = array('page callback' =&gt; 'mymod_do_it');

  return $items;
}


But this does not work. At the moment despair is joining me with this.

Any help would be very appreciated.

Thank You!
You might check out the 'Examples for Developers' project page for some relevant examples:
https://www.drupal.org/project/examples

I think you want to use hook_init instead of hook_menu. Try this:

function mymod_init() {
  if (drupal_is_front_page()){
    $items = array();

    $items['/'] = array('page callback' =&gt; 'mymod_do_it');

    return $items;
  }
}