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.










share|improve this question






















  • 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















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.










share|improve this question






















  • 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













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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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


















  • 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma