I want to execute cucumber in my computer.
in terminal I can execute cucumber ( cucumber feature )
and I can using crontab
but, I can't crontab execute shell script, shell script execute jar, jar execute cucumber in my environment
You can write a shell script to invoke cucumber command, like this:
/home/test.sh
#!/bin/bash
cd your_work_directory
cucumber -p test
Then execute 'crontab -e' command to edit your cron job, because crontab shell is not login-shell, so you need code like this:
0 1 * * * bash -lc '/home/test.sh'
If your cucumber need GUI environment, your code should be like this:
0 1 * * * env DISPLAY=:0 bash -lc '/home/test.sh'
Related
I have a bash script which has a sqoop exec and after it three impala commands. I want to run it but only when the previous execution has finished. Is this possible to be done in cronjob or in oozie?
I assume you are in a linux environment so you should be able to use the run-one command ( ubuntu run-one ) in conjunction with you bash script in a crontab.
e.g.
* * * * * cd /path/to/your/script && run-one ./your-script.sh
If not available you should be able to install if with your package manager
Working in Debian 8.5.
The installed cronjob looks like this:
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
*/1 * * * * /usr/local/bin/MySript.sh
#---------------------------------------------------------------
The bash script looks like this:
#!/bin/bash
cd /home/Path/to/executable/C/program
sh -c "xterm -e ./Cprogram" &
exit
When I execute the C program with ./MyScript.sh, the bash window pops up and the C program runs.
Cron won't run the script. The Daemon is running and cron is executing, as I see in /var/log/syslog
I overviewed all priviliges and I do everything as root.
I'd be very happy for any advice. Thanks in advance, JS
I have cron scheduler for jar execution which is internally running ruby script, when I run the cron command on command line it works fine, and gives no error. But when I execute same command through cron then it is giving status code 127. Considering the issue of environment variable(PATH) I tried to add . ~/.bash_profile; in cron command and run it again but it is giving me same status.
Below is the details of cron and ruby command:
Cron Command:
30 5 * * * . ~/.bash_profile; java -jar /usr/car_price/bin/carUtils.jar
Ruby command called by jar:
ruby /usr/car_price/bin/apiclient.rb > /usr/car_price/rubyLog/2015-01-07_05:30:04_TPA.log
Please help me to resolve the issue.
I wrote the following bash script named /home/pi/test.sh (that uses the ruby gem "tumblr-rb"):
#!/bin/bash
echo "starting script"
/usr/local/bin/tumblr post /home/pi/test.jpg --host=myhost.tumblr.com --credentials=/home/pi/.tumblr
echo "end of script"
If I run it from the command line, I get:
starting script
Post was successfully created! Post ID: 82238814640
end of script
And my picture gets posted to Tumblr. Then if I put the bash script in my pi user's crontab with * * * * * /home/pi/test.sh, I get the following cron output e-mailed to me:
starting script
end of script
And nothing gets posted to Tumblr. Why does nothing happen?
Cron passes a minimal set of environment variables to your jobs.
You can use a simple shell to check the environment crontab provided:
* * * * * env > /home/pi/cron_env.dat
Try to add the full path of your ruby binary to execute the ruby script.
You can also set the PATH variable in the crontab file, which will apply to all cron jobs. e.g.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
* * * * * bash -c /home/pi/test.sh
I have a ruby script that I have tested to be working that I would like to run as an hourly cron but cannot seem to get it firing properly.
The last thing I have tried was placing the line:
ruby ~/ruby_script.rb
in /etc/cron.hourly
Said ruby script is located in the home directory with:
#!/usr/bin/env ruby
as its top line.
I have looked into ruby & cron resources but they most seem to be for reoccurring tasks in a Ruby on Rails environment when I just want the script to run in my ubuntu environment. I have double checked that rails is installed as well.
I have had a lot of fun learning more about ubuntu over the past few months and will truly appreciate any assistance I receive here. Thank you in advance.
Try to use current user crontab
$ crontab -e
Add new cron job
0 * * * * /bin/bash -l -c 'ruby ~/ruby_script.rb'
Using bash command to run helps to get env variables during script execution.
(for tests change 0 to * - script will try to run every minute)
To log errors you can try to add command:
0 * * * * /bin/bash -l -c 'ruby ~/ruby_script.rb >> ~/ruby_script.log 2>&1 &'
Hope it helps.