sudo pear install mail
sudo pear install Net_SMTP
sudo pear install Auth_SASL
sudo pear install mail_mime
sudo pear install Net_SMTP
sudo pear install Auth_SASL
sudo pear install mail_mime
CREATE [AGGREGATE] FUNCTION function_name
RETURNS {STRING|INTEGER|REAL|DECIMAL}
CREATE FUNCTION SPLIT_STR(
x VARCHAR(255),
delim VARCHAR(12),
pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
delim, '');
SELECT SPLIT_STR(string, delimiter, position)
SELECT SPLIT_STR('a|bb|ccc|dd', '|', 3) as third;
+-------+
| third |
+-------+
| ccc |
+-------+
strategy_options:
DC1 : 3
DC2 : 3
$ crontab -e$ crontab -l# MIN HOUR MDAY MON DOW COMMAND
5 * * * * echo 'Hello'
Item Definition Valid Values
MIN Minute 0-60
HOUR Hour [24-hour clock] 0-23
MDAY Day of Month 1-31
MON Month 1-12 OR jan,feb,mar,apr …
DOW Day of Week 0-6 OR sun,mon,tue,wed,thu,fri,sat
COMMAND Command to be run Any valid command-line
Examples
Here are a few examples, to see what some entries look like.#Run command at 7:00am each weekday [mon-fri]
00 07 * * 1-5 mail_pager.script 'Wake Up'
#Run command on 1st of each month, at 5:30pm
30 17 1 * * pay_rent.script#Run command at 8:00am,10:00am and 2:00pm every day
00 8,10,14 * * * do_something.script#Run command every 5 minutes during market hours
*/5 6-13 * * mon-fri get_stock_quote.script#Run command every 3-hours while awake
0 7-23/3 * * * drink_water.script
Special Characters in Crontab
You can use an asterisk in any category to mean for every item, such as every day or every month.You can use commas in any category to specify multiple values. For example: mon,wed,friYou can use dashes to specify ranges. For example: mon-fri, or 9-17You can use forward slash to specify a repeating range. For example: */5 for every five minutes, hours, daysSpecial Entries
There are several special entries, some which are just shortcuts, that you can use instead of specifying the full cron entry.The most useful of these is probably @reboot which allows you to run a command each time the computer gets reboot. This could be useful if you want to start up a server or daemon under a particular user, or if you do not have access to the rc.d/init.d files.Example Usage:
# restart freevo servers
@reboot freevo webserver start
@reboot freevo recordserver startThe complete list:
Entry Description Equivalent To
@reboot Run once, at startup. None
@yearly Run once a year 0 0 1 1 *
@annually (same as @yearly) 0 0 1 1 *
@monthly Run once a month 0 0 1 * *
@weekly Run once a week 0 0 * * 0
@daily Run once a day 0 0 * * *
@midnight (same as @daily) 0 0 * * *
@hourly Run once an hour 0 * * * *
Miscelleanous Issues
Script Output
If there is any output from your script or command it will be sent to that user’s e-mail account, on that box. Using the default mailer which must be setup properly.You can set the variable MAILTO in the crontab to specify a separate e-mail address to use. For example:
MAILTO="admin@mydomain.com"Redirect Output to /dev/null
You can redirect the output from a cron script to /dev/null which just throws it away. By redirecting to /dev/null you will not receive anything from the script, even if it is throwing errors.
* * * * * /script/every_minute.pl > /dev/null 2>&1Missed Schedule Time
Cron does not run a command if it was missed. Your computer must be running for cron to run the job at the time it is scheduled. For example, if you have a 1:00am scheduled job and your computer was off at that time, it will not run the missed job in the morning when you turn it on.
CRON Examples
The following are a few CRON examples, and how to set them up in both interfaces.Example 1: Every 5 Minutes
Run every 5 minutes.SIMPLE INTERFACE
Minute Hour Day Month Day of Week
Every 5 All All All All
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
*/5****
Example 2: Yearly
Run yearly (at exactly midnight on January 1st).SIMPLE INTERFACE
Minute Hour Day Month Day of Week
0 Midnight 1 Jan All
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
0011*
Example 3: Monthly
Run monthly (at 2:15AM on the 5th of each month).SIMPLE INTERFACE
Minute Hour Day Month Day of Week
15 2AM 5 All All
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
1525**
Example 4: Weekly
Run weekly (at 4:32PM on every Thursday).SIMPLE INTERFACE
Minute Hour Day Month Day of Week
32 4PM All All Thu
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
3216**4
Example 5: Daily
Run daily (at 12:45AM every day).SIMPLE INTERFACE
Minute Hour Day Month Day of Week
45 Midnight All All All
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
450***
Example 5: Hourly
Run hourly (at 24 minutes past the hour).SIMPLE INTERFACE
Minute Hour Day Month Day of Week
24 All All All All
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
24****
Example 6 - Complex 1
Run 52 minutes after the hour every 4 hours (e.g. 12:52AM, 4:52AM, 8:52AM, etc…).SIMPLE INTERFACE
Minute Hour Day Month Day of Week
52 Every 4 All All All
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
52*/4***
Example 7 - Complex 2
Run 8, 22, and 47 minutes after the hour at 2AM and 2PM (e.g. 2:08AM, 2:22AM, 2:47AM, 2:08PM, 2:22PM, 2:47PM) of every third month.SIMPLE INTERFACE
Minute Hour Day Month Day of Week
8, 22, 47 2AM, 2PM All Jan, Apr, Aug, Dec All
ADVANCED INTERFACE
Minute Hour Day Month Day of Week
8,22,472,14**/3*
10.28.7.209=DC1:RAC1
10.28.7.218=DC1:RAC2
10.40.7.206=DC2:RAC1
10.40.7.191=DC2:RAC2
default=DC1:r1
bin/nodetool -h 10.40.7.206 ring
Address Status State Load Owns Token
131291297286969809762394636651102920798
10.40.7.191 Up Normal 11.01 GB 25.02% 3713143261524536428796724100157456993
10.28.7.218 Up Normal 21.79 GB 25.00% 46247024543280544328625128736684811735
10.40.7.206 Up Normal 11.01 GB 24.97% 88731726328828585514925390034962410388
10.28.7.209 Up Normal 22.19 GB 25.01% 131291297286969809762394636651102920798
With randompartitioner I inserted 1M records, and was expecting 1M rows on each node. I ended up with 1M each on DC1:RAC1 and DC1:RAC2, while ended up with just 75K each on DC2:RAC1 and DC2:RAC2.