A crontab file has five fields for specifying time intervals, followed by the command to be executed.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0-6 or 1-7) (Sunday = 0 and 7)
| | | +--------- month (1-12)
| | +------------- day of month (1-31)
| +----------------- hour (0-23)
+--------------------- minute (0-59)
In a Linux crontab file, day of week is unique because 0 and 7 both stand for Sunday, where one can use 0-6 or 1-7 to achieve the same result. However, a BusyBox crontab file treats 0 (zero) as Sunday. If you set the day of the week to 7, BusyBox will go nuts and run the command every day.
The character *
means "every"
. For example: A * * * * *
line would execute a command every minute, of every hour, of every day, of every week, of every month.
The character combination */
means "every/interval"
. For example: A */17 * * * *
line would execute a command every 17 minutes, and a * * */5 * *
line would execute a command every 5 days.
To view the crontab file, execute the following command.
crontab -l
Here is the crontab file from the My Cloud PR4100 NAS in its raw form. Note that several entries have leading zeros (00, 01, etc), which can potentially cause cron jobs to fail.
0 3 * * * /usr/sbin/daily_log_upload.sh &
0 3 * * * /usr/sbin/traceroute_wd.sh &
*/30 * * * * /usr/sbin/quota_monitor &
*/10 * * * * /usr/sbin/rlog -s /usr/local/modules/files/syslog_rotate.conf
01 */8 * * * [ -f /etc/init.d/atop ] && /etc/init.d/atop rotate
30 0 * * * /usr/local/sbin/ssl_cert_job.sh start > /var/log/ssl_cert_cron.out 2>&1
58 2 * * * /usr/local/sbin/PullWdlogConfig.sh
30 0 * * 1 logwdmsg -e &
0 3 * * * logwdmsg -o &
01 3 * * * /usr/local/sbin/LogDataSize.sh
00 3 * * * /usr/sbin/wd_rotate.sh
30 0 * * 1 /usr/sbin/wdappmgr_log_stats.py > /dev/null 2>&1 &
30 2 * * * /usr/sbin/stime&
0 3 * * * wd_crontab.sh&
0 4 * * * auto_fw -a -c&
0 0 * * * auto_clear_recycle_bin.sh &
30 3 * * * /usr/sbin/chk_wfs_download&
0 0 * * * random_check -s &
0 0 * * * expire.sh
7 13 * * * auto_fw -c 1 &
* * * * * sysinfo_update.sh
0 3 * * 1 getHddWhiteList.sh
Here is the crontab file the My Cloud PR4100 NAS, demystified and sorted by time intervals.
Every 1 minute
* * * * * sysinfo_update.sh
Every 10 minutes
*/10 * * * * /usr/sbin/rlog -s /usr/local/modules/files/syslog_rotate.conf
Every 30 minutes
*/30 * * * * /usr/sbin/quota_monitor &
First minute of every 8th hour
1 */8 * * * [ -f /etc/init.d/atop ] && /etc/init.d/atop rotate
**(Corrected from: 01 /8 * * )
Every day at 12:00 AM or 00:00 hours.
0 0 * * * auto_clear_recycle_bin.sh &
0 0 * * * random_check -s &
0 0 * * * expire.sh
Every day at 12:30 AM or 00:30 hours.
30 0 * * * /usr/local/sbin/ssl_cert_job.sh start > /var/log/ssl_cert_cron.out 2>&1
Every Day at 2:30 AM or 02:30 hours.
30 2 * * * /usr/sbin/stime&
Every day at 2:58 AM or 02:58 hours.
58 2 * * * /usr/local/sbin/PullWdlogConfig.sh
Every day at 3:00 AM or 03:00 hours.
0 3 * * * /usr/sbin/daily_log_upload.sh &
0 3 * * * /usr/sbin/traceroute_wd.sh &
0 3 * * * logwdmsg -o &
0 3 * * * wd_crontab.sh&
0 3 * * * /usr/sbin/wd_rotate.sh
*(Corrected from: 00 3 * * )
Every day at 3:01 AM or 03:01 hours.
1 3 * * * /usr/local/sbin/LogDataSize.sh
*(Corrected from: 01 3 * * )
Every day at 3:30 AM or 03:30 hours.
30 3 * * * /usr/sbin/chk_wfs_download&
Every day at 4:00 AM or 04:00 hours.
0 4 * * * auto_fw -a -c&
Every day at 1:07 PM or 13:07 hours.
7 13 * * * auto_fw -c 1 &
Monday at 12:30 AM or 00:30 hours.
30 0 * * 1 logwdmsg -e &
30 0 * * 1 /usr/sbin/wdappmgr_log_stats.py > /dev/null 2>&1 &
Monday at 3:00 AM or 03:00 hours.
0 3 * * 1 getHddWhiteList.sh
Portions of the crontab file originate from a config.xml file. Note that the <crond>
section of the config.xml file has malformed XML. In other words, element names can’t start with a number.
<crond>
<list>
<count>6</count>
<name id="1">stime</name>
<name id="2">wd_crontab</name>
<name id="3">fw_available</name>
<name id="4">app_get_info</name>
<name id="5">recycle_bin_clear</name>
<name id="6">chk_wfs_download</name>
</list>
<stime>
<count>1</count>
<item id="1">
<method>3</method>
<1>30</1>
<2>2</2>
<3>*</3>
<4>*</4>
<5>*</5>
<run>/usr/sbin/stime&</run>
</item>
</stime>
<wd_crontab>
<count>1</count>
<item id="1">
<method>3</method>
<1>0</1>
<2>3</2>
<3>*</3>
<4>*</4>
<5>*</5>
<run>wd_crontab.sh&</run>
</item>
</wd_crontab>
<fw_available>
<count>1</count>
<item id="1">
<method>3</method>
<1>0</1>
<2>3</2>
<3>*</3>
<4>*</4>
<5>*</5>
<run>auto_fw -c 1&</run>
</item>
</fw_available>
<app_get_info>
<count>1</count>
<item id="1">
<method>3</method>
<1>0</1>
<2>4</2>
<3>*</3>
<4>*</4>
<5>*</5>
<run>auto_fw -a -c&</run>
</item>
</app_get_info>
<recycle_bin_clear>
<count>1</count>
<item id="1">
<method>3</method>
<1>0</1>
<2>0</2>
<3>*</3>
<4>*</4>
<5>*</5>
<run>auto_clear_recycle_bin.sh &</run>
</item>
</recycle_bin_clear>
<chk_wfs_download>
<count>1</count>
<item id="1">
<method>3</method>
<1>30</1>
<2>3</2>
<3>*</3>
<4>*</4>
<5>*</5>
<run>/usr/sbin/chk_wfs_download&</run>
</item>
</chk_wfs_download>
</crond>
Other portions of the crontab file seem to originate from scripts or executable binary files. In addition, changes to the crontab file are reverted after some time has passed, likely because the entire root filesystem, with the exception of user share files, originates from a ramdisk. Otherwise, much remains unknown about exactly what each scheduled cron job does on the My Cloud series. In time, I hope to change this.