Trying to run Redis over Crontab

29 views
Skip to first unread message

gwbra

unread,
Jul 19, 2016, 8:15:22 AM7/19/16
to Redis DB
Hi everyone


I need to run at least twice a day this command

redis-cli del Allblocks

I was trying to run over the cron but perhaps does not execute the command, and I do manual works but during the cron does not work. I tried to creat a file.sh and execute them by cron the same thing. Manual works but using the cron not!!

How can I use the cron to execute commands on the redis??
My redis-cli is running daemon


Thanks everyone

Tuco

unread,
Jul 19, 2016, 11:46:06 PM7/19/16
to Redis DB
In cron, give the full path of redis-cli wherever redis-cli is present/installed.

George Chilumbu

unread,
Jul 26, 2016, 12:04:20 AM7/26/16
to Redis DB
You can simply just set a cron job to execute this command twice a day.

So at the bottom of your crontab (vim crontab -e), just add these two lines to run your command -  for example, to run twice a day at 2am and again at 2pm.

 0 2 * * * redis-cli del Allblocks
 0 14 * * * redis-cli del Allblocks


Just to test out, run this in a crontab and see how it work.
 * * * * * redis-cli info clients >> ~/clients_info.txt

So no need to write a script. You can run your command directly in your crontab.
Reply all
Reply to author
Forward
0 new messages