Skip to content

ProjectTasks

David Anderson edited this page Aug 10, 2023 · 3 revisions

Periodic tasks

Periodic tasks are programs that are run periodically. They are executed by the bin/start --cron program, which you should run from cron. To do this, run crontab -e and add a line of the form

0,5,10,15,20,25,30,35,40,45,50,55 * * * * HOME/projects/PROJECT/bin/start --cron

Periodic tasks are short-running, but in case they aren't, the 'start' script detect when an instance is still running and won't start another instance.

Your project's periodic tasks are described in its config.xml file, with elements of the following form:

<task>
   <cmd> get_load </cmd>
   <output> get_load.out </output>
   <period> 5 min </period>
   [ <host> host.ip </host>       ]
   [ <disabled>  0|1 </disabled>   ]
   [ <always_run> 0|1  </always_run> ]
</task>
<task>
   <cmd> run_in_ops update_forum_activities.php </cmd>
   <output> update_form_activities.out </output>
   <period> 1 day </period>
</task>
<task>
...
</task>

cmd

The command used to perform the task. Must be a program in the project's /bin directory.

You can run PHP scripts as periodic tasks. These scripts must be in the html/ops/ directory, and can be run with a command of the form

run_in_ops scriptname

The script should be executable, and should have the form

<?php
...
?>

You must specify the output file for such tasks (otherwise it will go to run_in_ops.out).

host

Specifies where the daemon should run. The default is the project's main host, as specified in config.xml.

period

The interval between executions, expressed as a single number (in units of minutes) or a number followed by 'seconds', 'minutes', 'hours', or 'days' (may be abbreviated to unique initial string).

output

Specifies the output file to output; and by default it is COMMAND_BASE_NAME.out. Output files are in log_X/, where X is the host.

disabled

Ignore this entry

always_run

Run this task regardless of whether or not the project is enabled (for example, a script that logs the current CPU load of the host machine).

A project newly created by make_project has periodic tasks that run the following:

db_dump

Write statistics data to XML files for export. Recommended period: 1 day.

update_profile_pages.php

Generate HTML files with lists of links to user profiles, organized alphabetically and by country. Recommended period: a few days.

update_stats

Update the recent average credit fields of users, teams, and hosts. This is important if you use send personalized mass emails or reminder emails, or use recent credit to enable message-board posting. Recommended period: daily.

update_uotd.php

Select a new User of the Day. Period: 1 day.

update_forum_activities.php

Recompute 'popularity' estimates for threads and posts in the Questions and Answers message boards. Recommended period: 1 hour.

team_import.php

Import new BOINC-wide teams from a central repository.

notify.php

Send notification digest emails to users. Recommended period: 1 day

delete_expired_tokens.php

Delete tokens stored on the token table (such as tokens used in confirming email address change or confirming the user wants to delete their account). Recommended period: 1 day

delete_expired_users_and_hosts.php

Delete users and hosts off of the user_deleted and host_deleted table when they are older than 60 days. This is the final step in the delete account process. Recommended period: 1 day.

The XML for these is:

  <tasks>
    <task>
      <output>
        db_dump.out
      </output>
      <cmd>
        db_dump -d 2 -dump_spec ../db_dump_spec.xml
      </cmd>
      <period>
        24 hours
      </period>
    </task>
    <task>
      <output>
        update_uotd.out
      </output>
      <cmd>
        run_in_ops update_uotd.php
      </cmd>
      <period>
        1 days
      </period>
    </task>
    <task>
      <output>
        update_forum_activities.out
      </output>
      <cmd>
        run_in_ops update_forum_activities.php
      </cmd>
      <period>
        1 hour
      </period>
    </task>
    <task>
      <output>
        update_stats.out
      </output>
      <cmd>
        update_stats
      </cmd>
      <period>
        1 days
      </period>
    </task>
    <task>
      <output>
        update_profile_pages.out
      </output>
      <cmd>
        run_in_ops update_profile_pages.php
      </cmd>
      <period>
        24 hours
      </period>
    </task>
    <task>
      <output>
        team_import.out
      </output>
      <cmd>
        run_in_ops team_import.php
      </cmd>
      <period>
        24 hours
      </period>
    </task>
    <task>
      <output>
        notify.out
      </output>
      <cmd>
        run_in_ops notify.php
      </cmd>
      <period>
        1 days
      </period>
    </task>
    <task>
        <cmd>run_in_ops ./delete_expired_tokens.php</cmd>
        <period>24 hours</period>
        <disabled>0</disabled>
        <output>delete_expired_tokens.out</output>
    </task>
    <task>
        <cmd>run_in_ops ./delete_expired_users_and_hosts.php</cmd>
        <period>24 hours</period>
        <disabled>0</disabled>
        <output>delete_expired_users_and_hosts.out</output>
    </task>
  </tasks>
Clone this wiki locally