All Projects → toniov → Gcalcron

toniov / Gcalcron

Schedule shell commands execution through Google Calendar

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gcalcron

Gcal Cli
Google Calendar command line tool for Node.js
Stars: ✭ 255 (+214.81%)
Mutual labels:  command-line-tool, google-calendar
Node Cron
A simple cron-like job scheduler for Node.js
Stars: ✭ 2,064 (+2448.15%)
Mutual labels:  cron, scheduled-tasks
Quartznet
Quartz Enterprise Scheduler .NET
Stars: ✭ 4,825 (+5856.79%)
Mutual labels:  cron, scheduled-tasks
Cronical
.NET-based cron daemon. Can replace Windows Services and Scheduled Tasks, typically for running service-like processes as part of an application suite - or just by itself.
Stars: ✭ 42 (-48.15%)
Mutual labels:  cron, scheduled-tasks
Cronmon
PHP Web app to monitor cron/scheduled tasks
Stars: ✭ 55 (-32.1%)
Mutual labels:  cron, scheduled-tasks
Pyinquirer
A Python module for common interactive command line user interfaces
Stars: ✭ 1,151 (+1320.99%)
Mutual labels:  command-line-tool
Fbi
Node.js workflow tool
Stars: ✭ 74 (-8.64%)
Mutual labels:  command-line-tool
Blendit
🖼 Blend images with text and generate amazing looking posters.
Stars: ✭ 68 (-16.05%)
Mutual labels:  command-line-tool
Runinbash
Run Linux commands under WSL without leaving your PowerShell or CMD!
Stars: ✭ 67 (-17.28%)
Mutual labels:  command-line-tool
Dark google calendar
Dark theme for Google Calendar.
Stars: ✭ 81 (+0%)
Mutual labels:  google-calendar
Jobber
An alternative to cron, with sophisticated status-reporting and error-handling
Stars: ✭ 1,217 (+1402.47%)
Mutual labels:  cron
Phalcon Cron
Cron component for Phalcon.
Stars: ✭ 73 (-9.88%)
Mutual labels:  cron
Dl
🍗 a concurrent http file downloader
Stars: ✭ 68 (-16.05%)
Mutual labels:  command-line-tool
Fleets
Automatically delete tweets, retweets, and favorites.
Stars: ✭ 75 (-7.41%)
Mutual labels:  cron
Ppgo job
PPGo_Job是一款可视化的、多人多权限的、一任务多机执行的定时任务管理系统,采用golang开发,安装方便,资源消耗少,支持大并发,可同时管理多台服务器上的定时任务。
Stars: ✭ 1,152 (+1322.22%)
Mutual labels:  cron
Spam Bot 3000
Social media research and promotion, semi-autonomous CLI bot
Stars: ✭ 79 (-2.47%)
Mutual labels:  command-line-tool
Cascadia
Go cascadia package command line CSS selector
Stars: ✭ 67 (-17.28%)
Mutual labels:  command-line-tool
Nexmo Cli
Nexmo CLI (Command Line Interface)
Stars: ✭ 73 (-9.88%)
Mutual labels:  command-line-tool
Sidekiq Scheduler
Lightweight job scheduler extension for Sidekiq
Stars: ✭ 1,198 (+1379.01%)
Mutual labels:  cron
Github Files Fetcher
Download a specific folder or file from a GitHub repo through command line
Stars: ✭ 73 (-9.88%)
Mutual labels:  command-line-tool

gcalcron

Schedule shell commands execution through Google Calendar

Google Calendar + Cron + Node.js

Super fast usage example

Start gcalcron:

$ gcalcron start '0 0 10 * * *'

[INFO] Process started checking your calendar: 10:00:00 every day

Insert an event starting at 10:00 through Google Calendar:

Back in the terminal:

[INFO] Executed: 'ls -l | grep file.txt'
-rw-r--r--    1 antonio  1796131739     11 Sep 24 15:14 file.txt

Installation

Install it as a global module:

$ npm install -g gcalcron

Usage

  1. Authenticate the app
  2. Start gcalcron, setting the check interval using cron syntax
  3. Schedule tasks inserting events in your calendar

1. Authentication

Authorization and authentication is done with OAuth 2.0.

Ok, this will take only about 2 minutes:

1.1 Get your project credentials

You will need a file with your credentials: client ID, client secret and redirect URI. This can be obtained in the Developer Console:

  • Go to your project
  • Click in Credentials
  • Click Create credentialsOAuth client ID (Application type must be Other)
  • Download the JSON file

1.2 Generate consent page URL

Once we got the credentials we must generate a consent page URL.

$ gcalcron generateUrl

(By default, the credentials will be searched in your home directory under the name client_secret.json)

The page will prompt you to authorize access, follow the instructions.

1.3 Get the token!

With the code we got through the authorization page, we can obtain a token and store it in our machine.

$ gcalcron storeToken <code>

(By default, the token is stored in your home folder under the name calendar_api_token.json).

NOTE: The token will expiry after one hour, but a refresh_token is included as well, allowing the app to refresh automatically the token each time it's used.

With this we are good to go. The stored token and credentials files will be required from now on to use this tool.

2. Start gcalcron

Syntax:

gcalcron start <cron-time> [--out <file> --err <file>]

<cron-time> must be in the form of cron syntax, with this the check frequency will be set.

--out <file> and --err <file> are optional, executed commands output and error output can be set using these options. By default, stdio and sterr will be used.

The next example will check your Google Calendar every hour printing the executed commands output in a text file:

$ gcalcron start '0 0 * * * *' --out ./output.txt

The Cron functionality is powered by node-cron, for more info about the syntax check the repository README.

3. Schedule tasks through Google Calendar

Event title

The events have to start with Execute:, followed by the shell command you want to execute.

Execute: /some/random/script.sh

Event description

The command can be specified in the event description instead, in case the description has content, the command in the title will be ignored.

NOTE: Execute: must be written always, what is ignored is whatever is written after Execute:.

Event start and end time

The range of time when the command will be executed. It will be executed only once, after it's executed the title of the event is renamed to from Execute: foo to [Executed] foo.

Recurring events will be executed once per occurrence.

NOTE: If, for example, an event is set from 20:00 to 21:00, you have to make sure that gcalcron is going to check your calendar at least once per hour.

Setting your own config

Using the option -C <file> you can set your own config. This file must be .js or .json.

Example:

/somepath/config.json

{
  "CRED_PATH": "/my/secret/path/credentials.json",
  "TOKEN_PATH": "/my/secret/path/token.json",
}
$ gcalcron -C /somepath/config.json generateUrl

$ gcalcron -C /somepath/config.json storeToken 1249asdjasop12

$ gcalcron -C /somepath/config.json start "0,30 * * * * *"

With the above config your token will be stored in /my/secret/path/credentials.json, and your token and credentials will be read from there as well.

The available options are:

CRED_PATH

Path to your credentials file. (Default: located in your home directory under the name client_secret.json)

TOKEN_PATH

Path to your token. (Default: located in your home directory under the name calendar_api_token.json)

CALENDAR_ID

The ID of the calendar you want to use. (Default: primary calendar)

LIST_ORDER

In case there are several events to be executed, this set the execution order (always ascending). Acceptable values are updated and startTime. (Default: startTime)

OUT_PATH

Write command output to a an specified file. (Default: stdout).

Same as the option -o, --output <file>. In case both are set, the option has preference.

ERR_PATH

Write command errors to a an specified file. (Default: stderr)

Same as the option -e, --error <file>. In case both are set, the option has preference.

SHELL

Shell to execute the command with. (Default: /bin/sh on UNIX, process.env.ComSpec on Windows)

API

Use the help command.

$ gcalcron help

Considerations

  • Use it under your own risk, if your Google Calendar account is compromised, malicious code could be executed.
  • The Google Calendar API has a limit of 1,000,000 queries per day, so it should be enough even if the check is executed once per second.
  • If you want to keep the process alive, consider using some tools like PM2 or forever.

Related

gcalcron can be used altogether with gcal to insert events programmatically. They share the same authentication process, so you can get to use it out-of-the-box.

License

MIT © Antonio V

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].