Running a global node module binary from crontab
up vote
0
down vote
favorite
I'm trying to run a node module (npm install -g lungo-cli
) from within my crontab
.
What I've tried is to call the node binary from crontab:
* * * * * lungo
No luck.
Then I tried with:
* * * * * /usr/local/bin/lungo
Again, no luck.
So finally I did what I thought it was a workaround, calling the node module directly from a javascript file using shelljs.
Javascript:
const shell = require('shelljs')
shell.exec('lungo')
I even tried running it locally!
const lungo = require('lungo-cli/bin/lungo')
const shell = require('shelljs')
const shell.exec('lungo')
Crontab:
* * * * * /usr/local/bin/node $HOME/scripts/lungo.js
And it's the same, it's not working, it seems like crontab
is running in a completely different environment than my zsh
shell and can't find any binaries other than the OSX specific ones like cat
, rm
, cd
and so on.
I'm using Mac OSX 10.14.1 (Mojave) and zsh
as my shell.
How could I accomplish this? I want to be able to call my node cli programs with crontab.
node.js bash cron node-modules
add a comment |
up vote
0
down vote
favorite
I'm trying to run a node module (npm install -g lungo-cli
) from within my crontab
.
What I've tried is to call the node binary from crontab:
* * * * * lungo
No luck.
Then I tried with:
* * * * * /usr/local/bin/lungo
Again, no luck.
So finally I did what I thought it was a workaround, calling the node module directly from a javascript file using shelljs.
Javascript:
const shell = require('shelljs')
shell.exec('lungo')
I even tried running it locally!
const lungo = require('lungo-cli/bin/lungo')
const shell = require('shelljs')
const shell.exec('lungo')
Crontab:
* * * * * /usr/local/bin/node $HOME/scripts/lungo.js
And it's the same, it's not working, it seems like crontab
is running in a completely different environment than my zsh
shell and can't find any binaries other than the OSX specific ones like cat
, rm
, cd
and so on.
I'm using Mac OSX 10.14.1 (Mojave) and zsh
as my shell.
How could I accomplish this? I want to be able to call my node cli programs with crontab.
node.js bash cron node-modules
Is it working in a script file? Make it work in a script, add whatever needed to the script, export variables, add the#!/bin/bash
whatever needed. Then point the crontab to the script file. It will be much easier to debug.
– yeya
Nov 10 at 22:35
I've also tried writing a script file with the shebang and all stuff, it's not working either, I outputted anecho
to a log file and that does work, however, the node cli binary gets lost and never executes.
– bntzio
Nov 10 at 22:53
Did you try other node module? It could be an issue with the lungo app itself, not the lungo-cli. Maybe the lungo-cli expect some extra enviromet variables to exist that are not available in crontab context. Anyway it looks like a very basic package, try to execute the command itself without the node package. look here: github.com/sindresorhus/lungo-cli/blob/master/api.js#L15
– yeya
Nov 10 at 23:09
It works outside crontab, even using shelljs, the problem is the crontab enviroment not reading the global node bin.
– bntzio
Nov 10 at 23:33
Just made it run with success with this crontab:* * * * * /usr/local/bin/node /usr/local/lib/node_modules/lungo-cli./cli.js
although I want to execute the binary.
– bntzio
Nov 10 at 23:56
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to run a node module (npm install -g lungo-cli
) from within my crontab
.
What I've tried is to call the node binary from crontab:
* * * * * lungo
No luck.
Then I tried with:
* * * * * /usr/local/bin/lungo
Again, no luck.
So finally I did what I thought it was a workaround, calling the node module directly from a javascript file using shelljs.
Javascript:
const shell = require('shelljs')
shell.exec('lungo')
I even tried running it locally!
const lungo = require('lungo-cli/bin/lungo')
const shell = require('shelljs')
const shell.exec('lungo')
Crontab:
* * * * * /usr/local/bin/node $HOME/scripts/lungo.js
And it's the same, it's not working, it seems like crontab
is running in a completely different environment than my zsh
shell and can't find any binaries other than the OSX specific ones like cat
, rm
, cd
and so on.
I'm using Mac OSX 10.14.1 (Mojave) and zsh
as my shell.
How could I accomplish this? I want to be able to call my node cli programs with crontab.
node.js bash cron node-modules
I'm trying to run a node module (npm install -g lungo-cli
) from within my crontab
.
What I've tried is to call the node binary from crontab:
* * * * * lungo
No luck.
Then I tried with:
* * * * * /usr/local/bin/lungo
Again, no luck.
So finally I did what I thought it was a workaround, calling the node module directly from a javascript file using shelljs.
Javascript:
const shell = require('shelljs')
shell.exec('lungo')
I even tried running it locally!
const lungo = require('lungo-cli/bin/lungo')
const shell = require('shelljs')
const shell.exec('lungo')
Crontab:
* * * * * /usr/local/bin/node $HOME/scripts/lungo.js
And it's the same, it's not working, it seems like crontab
is running in a completely different environment than my zsh
shell and can't find any binaries other than the OSX specific ones like cat
, rm
, cd
and so on.
I'm using Mac OSX 10.14.1 (Mojave) and zsh
as my shell.
How could I accomplish this? I want to be able to call my node cli programs with crontab.
node.js bash cron node-modules
node.js bash cron node-modules
asked Nov 10 at 22:19
bntzio
574520
574520
Is it working in a script file? Make it work in a script, add whatever needed to the script, export variables, add the#!/bin/bash
whatever needed. Then point the crontab to the script file. It will be much easier to debug.
– yeya
Nov 10 at 22:35
I've also tried writing a script file with the shebang and all stuff, it's not working either, I outputted anecho
to a log file and that does work, however, the node cli binary gets lost and never executes.
– bntzio
Nov 10 at 22:53
Did you try other node module? It could be an issue with the lungo app itself, not the lungo-cli. Maybe the lungo-cli expect some extra enviromet variables to exist that are not available in crontab context. Anyway it looks like a very basic package, try to execute the command itself without the node package. look here: github.com/sindresorhus/lungo-cli/blob/master/api.js#L15
– yeya
Nov 10 at 23:09
It works outside crontab, even using shelljs, the problem is the crontab enviroment not reading the global node bin.
– bntzio
Nov 10 at 23:33
Just made it run with success with this crontab:* * * * * /usr/local/bin/node /usr/local/lib/node_modules/lungo-cli./cli.js
although I want to execute the binary.
– bntzio
Nov 10 at 23:56
add a comment |
Is it working in a script file? Make it work in a script, add whatever needed to the script, export variables, add the#!/bin/bash
whatever needed. Then point the crontab to the script file. It will be much easier to debug.
– yeya
Nov 10 at 22:35
I've also tried writing a script file with the shebang and all stuff, it's not working either, I outputted anecho
to a log file and that does work, however, the node cli binary gets lost and never executes.
– bntzio
Nov 10 at 22:53
Did you try other node module? It could be an issue with the lungo app itself, not the lungo-cli. Maybe the lungo-cli expect some extra enviromet variables to exist that are not available in crontab context. Anyway it looks like a very basic package, try to execute the command itself without the node package. look here: github.com/sindresorhus/lungo-cli/blob/master/api.js#L15
– yeya
Nov 10 at 23:09
It works outside crontab, even using shelljs, the problem is the crontab enviroment not reading the global node bin.
– bntzio
Nov 10 at 23:33
Just made it run with success with this crontab:* * * * * /usr/local/bin/node /usr/local/lib/node_modules/lungo-cli./cli.js
although I want to execute the binary.
– bntzio
Nov 10 at 23:56
Is it working in a script file? Make it work in a script, add whatever needed to the script, export variables, add the
#!/bin/bash
whatever needed. Then point the crontab to the script file. It will be much easier to debug.– yeya
Nov 10 at 22:35
Is it working in a script file? Make it work in a script, add whatever needed to the script, export variables, add the
#!/bin/bash
whatever needed. Then point the crontab to the script file. It will be much easier to debug.– yeya
Nov 10 at 22:35
I've also tried writing a script file with the shebang and all stuff, it's not working either, I outputted an
echo
to a log file and that does work, however, the node cli binary gets lost and never executes.– bntzio
Nov 10 at 22:53
I've also tried writing a script file with the shebang and all stuff, it's not working either, I outputted an
echo
to a log file and that does work, however, the node cli binary gets lost and never executes.– bntzio
Nov 10 at 22:53
Did you try other node module? It could be an issue with the lungo app itself, not the lungo-cli. Maybe the lungo-cli expect some extra enviromet variables to exist that are not available in crontab context. Anyway it looks like a very basic package, try to execute the command itself without the node package. look here: github.com/sindresorhus/lungo-cli/blob/master/api.js#L15
– yeya
Nov 10 at 23:09
Did you try other node module? It could be an issue with the lungo app itself, not the lungo-cli. Maybe the lungo-cli expect some extra enviromet variables to exist that are not available in crontab context. Anyway it looks like a very basic package, try to execute the command itself without the node package. look here: github.com/sindresorhus/lungo-cli/blob/master/api.js#L15
– yeya
Nov 10 at 23:09
It works outside crontab, even using shelljs, the problem is the crontab enviroment not reading the global node bin.
– bntzio
Nov 10 at 23:33
It works outside crontab, even using shelljs, the problem is the crontab enviroment not reading the global node bin.
– bntzio
Nov 10 at 23:33
Just made it run with success with this crontab:
* * * * * /usr/local/bin/node /usr/local/lib/node_modules/lungo-cli./cli.js
although I want to execute the binary.– bntzio
Nov 10 at 23:56
Just made it run with success with this crontab:
* * * * * /usr/local/bin/node /usr/local/lib/node_modules/lungo-cli./cli.js
although I want to execute the binary.– bntzio
Nov 10 at 23:56
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243987%2frunning-a-global-node-module-binary-from-crontab%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is it working in a script file? Make it work in a script, add whatever needed to the script, export variables, add the
#!/bin/bash
whatever needed. Then point the crontab to the script file. It will be much easier to debug.– yeya
Nov 10 at 22:35
I've also tried writing a script file with the shebang and all stuff, it's not working either, I outputted an
echo
to a log file and that does work, however, the node cli binary gets lost and never executes.– bntzio
Nov 10 at 22:53
Did you try other node module? It could be an issue with the lungo app itself, not the lungo-cli. Maybe the lungo-cli expect some extra enviromet variables to exist that are not available in crontab context. Anyway it looks like a very basic package, try to execute the command itself without the node package. look here: github.com/sindresorhus/lungo-cli/blob/master/api.js#L15
– yeya
Nov 10 at 23:09
It works outside crontab, even using shelljs, the problem is the crontab enviroment not reading the global node bin.
– bntzio
Nov 10 at 23:33
Just made it run with success with this crontab:
* * * * * /usr/local/bin/node /usr/local/lib/node_modules/lungo-cli./cli.js
although I want to execute the binary.– bntzio
Nov 10 at 23:56