I setup composer by following this guide: http://codybonney.com/installing-composer-globally-on-centos-6-4/
it is ok. I could run composer globally.
The problem is that I want to run composer update with cron job.
05 15 * * * cd ~/myproject && composer update --no-dev > ~/composer.tx
error: /bin/sh: composer: command not found
Please help me
Thanks
/bin/sh is probably not the shell you normally use (bash), and it probably has different path settings.
Add the full path to the command so you don't need to change dirs
05 15 * * * /home/user/myproject/composer
...or write your command like ./composer
I solved my problem by using full path to composer installed folder
05 15 * * * cd ~/myproject && /usr/local/bin/composer update --no-dev > ~/composer.tx
Related
I have a simple python project to water my plants, it works with a Raspberry and RaspberryPi os lite.
In the project I have a package named app with a __main__.py to launch it, I just type python -m app in the terminal and it works fine.
I tried to make a crontab with * * * * * /usr/bin/python /home/pi/djangeau/app
Nothing happens, whereas if I launch a simple python test script it does.
The cron log gives me that error : 'No MTA installed, discarding output' , not sure this is useful to solve the problem.
I hope I was clear enough. Thank you for your answers. Vincent
MTA is for mailing purposes as cron sends email whereas ubuntu doesn't have MTA. Below is the link for a better understanding:
https://askubuntu.com/questions/222512/cron-info-no-mta-installed-discarding-output-error-in-the-syslog
Finally I figured out:
For exemple that command in bash : python -m app
is equivalent to this one for a crontab :
* * * * * cd /home/pi/djangeau && /usr/bin/python -m app
Just replace the correct path and stars by the schedule you want
I know that you can run a Node.js script in Crontab by doing something like:
0 * * * * node /path/to/your/script.js
But I want to run a Node.js app, not a script, using Crontab. I created a Node.js app in order to write some automated tests using Mocha, Chai and Selenium, and I want to run it periodically by using Crontab. How would I go about doing this? I currently run my app by writing in the command line:
npm run api-pro
Where api-pro is a script from my package.json that invokes some tests for the production api.
Note that if I simply try to write a Crontab job with the command "npm run api-pro" it doesn't recognize the command npm (and obviously I do have Node installed in my computer).
My guess is that the user cron use do not configure the PATH in the same way as your user, and do not know node nor npm.
What you can try is to use the command which node to know where your node binary is (/some/path/to/node)
Then you can use the absolute path in your crontab:
0 * * * * /some/path/to/node /path/to/your/script.js
EDIT:
The difference between adding node and npm to $PATH and using absolute paths is that absolute path will work for one executable, since Linux will not have to search the PATH.
Adding to the PATH will make Linux recognize node and npm just as in your user. The fact that they are in the same folder do not affect that.
For anyone trying to run with npm, here were my steps to get it working on MacOS 12.3.1, using node/npm installed by brew.
Note, this is inflexible, and the PATH will need to be updated if brew updates its paths again:
Print two things we will need
echo $PATH
// /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:...
which npm
// /opt/homebrew/bin/npm
Open crontab with EDITOR="vim" crontab -e
Add these two lines
PATH={what you copied from step 1}
* * * * * cd {your_project_dir_where_package.json_lives} && {location_of_npm_from_step_1} run start >>/tmp/crontab.log 2>&1
Note: The >>/tmp/crontab.log 2>&1 is to help you debug. You can tail -f /tmp/crontab.log in another terminal to watch for STDOUT or STDERR
I guess that by using crontab, you're running your node app on a Linux machine so why don't you write a simple bash script ?
run_test.bash
#!/bin/bash
cd /path/to/your/app && \
npm run api-pro
then your crontab should look like :
0 * * * * /path/to/your/bash/script/run_test.bash
Of course, your script will have to be executable for your user :
$ chmod u+x run_test.bash
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.
I'm using Oh-my-zsh in my macbook so I've tried many things to get the crontab task runs but finally, my solution was prepending the .zshrc before the command to run.
*/30 * * * * . $HOME/.zshrc; node /path/for/my_script.js
This task runs every 30 minutes and uses .zshrc profile to execute my node command. Don't forget to use the dot before the $HOME var.
By the way, you can run any command attached to your zsh environment.
I am trying to install STworkbench on ubuntu 12.04 but i get an error as below:
************************************************************************
* Looks like you are trying to install on a Ubuntu system *
* *
* This is not officially supported, but can be made to work *
* *
* Look at the following links and carry out the steps listed there *
* and then rerun this script with the --debian flag *
* *
http://stlinux.com/install/ubuntu *
* *
************************************************************************
I followed the installation guide from http://www.stlinux.com/devel/stw.
What can i do to fix this?
Have you tried to add "-d" in your install command:
$ ./install -d stworkbench
I have the following Dockerfile with jenkins as the base image:
FROM jenkins
USER root
ENV JENKINS_MIRROR http://mirrors.jenkins-ci.org
RUN for plugin in git-client git ws-cleanup ; do wget -O $JENKINS_HOME/plugins/${plugin}.hpi $JENKINS_MIRROR/plugins/${plugin}/latest/${plugin}.hpi ; done
EXPOSE 8080
I'm trying to install some additional plugins but it gives me an error saying no such file or directory
I then started and connected to the container of this build step in order to "debug" the error:
However, I could not find out the cause because every directory seems to exist. Furthermore, if I then run the for-loop manually in the bash, all plugins are installed correctly...
I further noticed, that the installation of the the plugins works, if I install them in the root directory as follows:
RUN for plugin in git-client git ws-cleanup ; do wget -O ${plugin}.hpi $JENKINS_MIRROR/plugins/${plugin}/latest/${plugin}.hpi ; done
However, this is the wrong place as they have to be placed in the directory $JENKINS_HOME/plugins
Why I am not able to install the plugins in $JENKINS_HOME/plugins?
I can't read your screenshots, but you don't seem to be following the official instructions. See https://github.com/cloudbees/jenkins-ci.org-docker under "Installing more tools". Note:
You should save the plugins to /usr/share/jenkins/ref/plugins
You could use a plugins.txt file instead, which contains the names of your plug-ins, and you can process with the provided plugins.sh script. This looks like:
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/plugins.txt
I think the reason your approach wasn't working was to do with some processing in the start-up script.
install-plugins.sh is deprecated. I had to switch to jenkins-plugin-cli:
FROM jenkins/jenkins
...
RUN jenkins-plugin-cli \
--plugins \
git \
workflow-aggregator \
blueocean \
other-plugins
jenkins-plugin-cli also supports -f parameter, which gets the list of plugins as a file.
See Jenkins Official Documentation for details.