cron job for redis-cli commands

1,447 views
Skip to first unread message

chilumb...@gmail.com

unread,
Nov 10, 2015, 3:38:12 AM11/10/15
to Redis DB
I have a cron job set to run every minute by executing a script with the following redis-cli command:

# !/user/bin/
redis
-cli info clients >> /tmp/outout


All the file permissions are correct. But i cannot get any output.

How can i schedule redid-cli commands using a cron job?

Jan-Erik Rediger

unread,
Nov 10, 2015, 3:46:53 AM11/10/15
to redi...@googlegroups.com
In theory that should work.
If it doesn't you may hit a problem, which in turn might be written to
stderr.
So either you get mails from that cronjob with the output or you need to
save the output otherwise.

Does that command work for you when executed manually?
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.

chilumb...@gmail.com

unread,
Nov 10, 2015, 4:05:56 AM11/10/15
to Redis DB, jan...@fnordig.de
Yes, it works when i execute the command in the terminal directly.

But also when i try other linux commands in the same script e.g, ls -l, they work just fine. Or even the commands "echo" and also "date".

So not sure why the redid-cli commands won't work. About saving the output, it is being redirected to a file. The permissions for that file are ok with all users allowed to write to it. 

Jan-Erik Rediger

unread,
Nov 10, 2015, 4:16:48 AM11/10/15
to Redis DB
You only redirect stdout of that redis-cli call.
Redirect stdout AND stderr of the cronjob to a file (or make sure your
cron is able to send that output via email)
> > an email to redis-db+u...@googlegroups.com <javascript:>.
> > > To post to this group, send email to redi...@googlegroups.com
> > <javascript:>.

chilumb...@gmail.com

unread,
Nov 10, 2015, 5:17:17 AM11/10/15
to Redis DB, jan...@fnordig.de
I am redirecting to both now, and the output is:
/bin/rediscon: 2: /bin/rediscon: redis-cli: not found




Would moving the script in the redis folder where the redis-cli resides help? 

Itamar Haber

unread,
Nov 10, 2015, 5:20:30 AM11/10/15
to redi...@googlegroups.com, Jan-Erik Rediger
Why not install redis-cli on the server (or just copy it /usr/local/bin)?

To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.

Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Chief Developer Advocate & Senior Solution Architect
Redis Watch Newsletter - Curator and Janitor
Redis Labs - home of Redis

Mobile: +1 (415) 688 2443
Office: +1 (650) 396 2999 Ext. 123
Mobile (IL): +972 (54) 567 9692
Office (IL): +972 (3) 720 8515 Ext. 123
Email: ita...@redislabs.com
Twitter: @itamarhaber
Skype: itamar.haber

Blog  |  Twitter  |  LinkedIn


chilumb...@gmail.com

unread,
Nov 10, 2015, 5:26:01 AM11/10/15
to Redis DB, jan...@fnordig.de
Its working now.

Instead of creating a new script, i must use the redis-cli script

Thanks :) 


On Tuesday, November 10, 2015 at 5:16:48 PM UTC+8, janerik wrote:

chilumb...@gmail.com

unread,
Nov 10, 2015, 8:27:27 AM11/10/15
to Redis DB, jan...@fnordig.de
I used the redis client that comes bundled with the server and its now working.

Thanks all for the help
Reply all
Reply to author
Forward
0 new messages