Skip to content

Commit

Permalink
Docs: Recipe for running gulp via cron task (#2034)
Browse files Browse the repository at this point in the history
  • Loading branch information
romellem authored and phated committed Nov 3, 2017
1 parent c4d219e commit 2c6d551
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
* [Run Grunt Tasks from Gulp](run-grunt-tasks-from-gulp.md)
* [Exports as tasks](exports-as-tasks.md)
* [Rollup with rollup-stream](rollup-with-rollup-stream.md)
* [Run gulp task via cron job](cron-task.md)
25 changes: 25 additions & 0 deletions docs/recipes/cron-task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Run gulp task via cron job

While logged in via a user that has privileges to run `gulp`, run the following:

crontab -e

to edit your current "[crontab](https://en.wikipedia.org/wiki/Cron)" file.

Typically, within a cron job, you want to run any binary using absolute paths,
so an initial approach to running `gulp build` every minute might look like:

* * * * * cd /your/dir/to/run/in && /usr/local/bin/gulp build

However, you might see in the cron logs that you get this error:

> `/usr/bin/env: node: No such file or directory`
To fix this, we need to add a [symbolic link](https://en.wikipedia.org/wiki/Ln_\(Unix\))
within `/usr/bin` to point to the actual path of our node binary.

Be sure you are logged in as a **sudo** user, and paste in the following command to your terminal:

sudo ln -s $(which node) /usr/bin/node

Once this link is established, your cron task should run successfully.

0 comments on commit 2c6d551

Please sign in to comment.