CRON
From DD-WRT Wiki
Revision as of 20:25, 10 July 2006 (edit) Gerrys (Talk | contribs) ← Previous diff |
Revision as of 18:17, 16 July 2006 (edit) (undo) MikeT (Talk | contribs) (→Pre-requisites) Next diff → |
||
Line 3: | Line 3: | ||
== Pre-requisites == | == Pre-requisites == | ||
- | In order for cron to function properly, you must have the date and time set correctly. | + | In order for cron to function properly, you must have the date and time set correctly. |
- | + | You can check this in the GUI by going to: | |
- | + | * Status | |
+ | ** Router tab | ||
+ | *** Current Time. | ||
+ | You can also check the time in the command line by using the 'date' command. | ||
+ | You must also enable ''crontab'' in DD-WRT before you can use it. | ||
+ | You can enable crontab in the GUI by going to: | ||
+ | * Administration | ||
+ | ** Management | ||
+ | *** Cron | ||
+ | and set it to enable. | ||
== File Locations == | == File Locations == |
Revision as of 18:17, 16 July 2006
The crontab command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically. Dreamhost crontab wiki has a good explanation of how crontab works. A more official explanaton can be found here.
Contents |
Pre-requisites
In order for cron to function properly, you must have the date and time set correctly. You can check this in the GUI by going to:
- Status
- Router tab
- Current Time.
- Router tab
You can also check the time in the command line by using the 'date' command.
You must also enable crontab in DD-WRT before you can use it. You can enable crontab in the GUI by going to:
- Administration
- Management
- Cron
- Management
and set it to enable.
File Locations
Cron can be set in two locations on dd-wrt:
1. Either by putting your command in the /tmp/crontab file
echo ' * * * * * root /bin/date > /tmp/test.txt' >> /tmp/crontab
which will look like this:
* * * * * root /bin/date > /tmp/test.txt
2. Or by putting a file in the /tmp/cron.d/ folder (eg. /tmp/cron.d/dosomething) that holds your command
echo '* * * * * root /bin/date > /tmp/test.txt' > /tmp/cron.d/date
which will look like this:
* * * * * root /bin/date > /tmp/test.txt
Restarting Crond
After you modify/add the appropriate command you will need to restart cron in order for your changes to take effect. You can restart crond with the following command:
killall -9 crond; crond
Since end of June cron changed to crond!!!
Extras
You may wish to add this to your startup script, before any jobs are added. It will add clarity to your crontab file:
echo '# minute (0-59),' >> /tmp/crontab echo '# | hour (0-23),' >> /tmp/crontab echo '# | | day of the month (1-31),' >> /tmp/crontab echo '# | | | month of the year (1-12),' >> /tmp/crontab echo '# | | | | day of the week (0-6 with 0=Sunday).' >> /tmp/crontab echo '# | | | | | commands' >> /tmp/crontab
If you add this to your startup script, you will see this in your crontab file:
# minute (0-59), # | hour (0-23), # | | day of the month (1-31), # | | | month of the year (1-12), # | | | | day of the week (0-6 with 0=Sunday). # | | | | | commands