| 1 | = Periodic tasks = |
| 2 | |
| 3 | '''Periodic tasks''' are programs that are run periodically. They are executed by the [StartTool bin/start --cron] program, which you should run from cron. To do this, run crontab and add a line of the form |
| 4 | {{{ |
| 5 | 0,5,10,15,20,25,30,35,40,45,50,55 * * * * HOME/projects/PROJECT/bin/start --cron |
| 6 | }}} |
| 7 | |
| 8 | 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. |
| 9 | |
| 10 | Your project's periodic tasks are described in its [ProjectConfigFile config.xml] file, with elements of the following form: |
| 11 | |
| 12 | {{{ |
| 13 | <task> |
| 14 | <cmd> get_load </cmd> |
| 15 | <output> get_load.out </output> |
| 16 | <period> 5 min </period> |
| 17 | [ <host> host.ip </host> ] |
| 18 | [ <disabled> 1 </disabled> ] |
| 19 | [ <always_run> 1 </always_run> ] |
| 20 | </task> |
| 21 | <task> |
| 22 | <cmd> echo "HI" | mail root@example.com </cmd> |
| 23 | <output> /dev/null </output> |
| 24 | <period> 1 day </period> |
| 25 | </task> |
| 26 | <task> |
| 27 | ... |
| 28 | </task> |
| 29 | }}} |
| 30 | |
| 31 | cmd:: |
| 32 | The command used to perform the task. Must be a program in the project's /bin directory. |
| 33 | |
| 34 | 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 |
| 35 | {{{ |
| 36 | run_in_ops scriptname |
| 37 | }}} |
| 38 | The script should be executable, and should have the form |
| 39 | {{{ |
| 40 | #! /usr/bin/env php |
| 41 | <?php |
| 42 | ... |
| 43 | ?> |
| 44 | }}} |
| 45 | You must specify the output file for such tasks (otherwise it will go to run_in_ops.out). |
| 46 | host:: |
| 47 | Specifies where the daemon should run. The default is the project's main host, as specified in config.xml. |
| 48 | period:: |
| 49 | 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). |
| 50 | output:: |
| 51 | 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. |
| 52 | disabled:: |
| 53 | Ignore this entry |
| 54 | always_run:: |
| 55 | 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). |
| 56 | |
| 57 | A project newly created by [MakeProject make_project] has no periodic tasks. Here are some programs you might want to run as periodic tasks: |
| 58 | |
| 59 | db_dump:: |
| 60 | Write statistics data to XML files for export. Details are [DbDump here]. Recommended period: 1 day. |
| 61 | update_profile_pages.php:: |
| 62 | Generate HTML files with lists of links to user profiles, organized alphabetically and by country. Recommended period: a few days. |
| 63 | update_stats -update_teams -update_users -update_hosts:: |
| 64 | Update the recent average credit fields of users, teams, and hosts. This is important if you use send personalized [VolunteerRecruit mass emails] or [http://boinc.berkeley.edu/reminder_email.php reminder emails], or use recent credit to enable message-board posting. Recommended period: every few days. |
| 65 | update_uotd.php:: |
| 66 | Select a new User of the Day. Period: 1 day. |
| 67 | update_forum_activities.php:: |
| 68 | Recompute 'popularity' estimages for threads and posts in the Questions and Answers message boards. Recommended period: 1 hour. |