Sonalkumar sute
Sonalkumar sute

Reputation: 2575

execute shell script from crontab

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

Upvotes: 0

Views: 482

Answers (2)

Milind
Milind

Reputation: 5112

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

Upvotes: 1

mzedeler
mzedeler

Reputation: 4369

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

* * * * * * /path/to/script.sh

Upvotes: 1

Related Questions