Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
Was very busy lately working on a new project for a client. One of the key requirements in the project is to create a micro service to poll from external data sources for every two minutes, from 8am to 6pm, Monday to Friday and update the database with the latest data.
After testing out my Go program. I need to put in a crontab to start polling the data.
From the Linux Crontab configuration, the parameters are in such order :
MIN HOUR DOM MON DOW CMD
Explanation:
MIN - Minute field and can be 0 to 59
HOUR - Hour field and can be 0 to 23
DOM - Day of Month and can be 1-31
MON - Month field and can be 1-12
DOW - Day Of Week and can be 0-6
CMD - Comman to be executed.
Therefore, to achieve my objective, the final crontab configuration should look like this :
*/2 08-18 * * 1-5 /microservices/go-poll-and-update-summary-data
Hope this helps!
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+7.1k Golang : Validate credit card example
+22.9k Golang : Gorilla mux routing example
+6.8k Golang : Calculate pivot points for a cross
+14.1k Golang : Check if a file exist or not
+8.2k Golang : Qt splash screen with delay example
+20.8k Golang : Underscore or snake_case to camel case example
+22.2k Golang : Convert seconds to minutes and remainder seconds
+10.5k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+23.1k Golang : Randomly pick an item from a slice/array example
+4.5k Java : Generate multiplication table example
+17k Golang : Capture stdout of a child process and act according to the result
+18.6k Golang : Find IP address from string