.Maui Blog

Execute .go file using crontab in Ubuntu

The first thing to do is to compile the .go file to make it executable:

go build myfile.go

This will produce a file called myfile that is executable.
After that run the command from the Ubuntu terminal to open the crontab:

crontab -e

Insert at the bottom of the file the command to execute the script as shown in the example:

*/1 * * * * cd /path/to/my/file && ./myfile
Exit mobile version