0

Trying to execute shell script from crontab, every 10 seconds but it is not working for me

* * * * * sleep 10 /path/dataimport.sh

script just has one command rake db:dataimport

3
  • cron only allows down to the level of minutes not seconds so maybe you need a background process that is constantly running rather than a cron job? Commented Jul 16, 2015 at 8:31
  • Can you explain what you mean by "not working". Is it not running the script? Or not running the script when you expect it to? Commented Jul 16, 2015 at 8:40
  • @Shadwell shellscript itself not calling Commented Jul 16, 2015 at 8:48

2 Answers 2

1

The highest resolution for cron is minutes, so you can make the script run every minute like this :

* * * * * * /path/to/script.sh 
Sign up to request clarification or add additional context in comments.

4 Comments

Sorry - an asterisk was missing. Try taking a look at the manual: nncron.ru/help/EN/working/cron-format.htm
thanks, I puted like this * * * * * root $APP_DIR/script/dataimport.sh and * * * * * $APP_DIR/script/dataimport.sh
sorry I puted like that, but still it is not working
You need six asterisks ("*"). Not five.
1

if you really want to do it in a simple way..you must use Whenever Gem,made only for this purpose so that you can use plain simple words instead of scripting language for working on Cron jobs.

install it,generate the schedule.rb file using the generator and write the recurring tasks easily.

every 10.seconds do command "/usr/bin/my_great_command" end 

you can also use:-

##to run the scripts in schedule.rb bundle exec whenever ##update schedule.rb and run this to update and view your crontabs whenever --update-crontab 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.