sphinx delta search indexing and merge in cron job - sphinx

I had implemented delta indexing in cron job and which is
*/2 * * * * /usr/bin/indexer --config /etc/sphinx/sphinx.conf indexer sph_idx_posts_delta --rotate > /var/log/cronlog4.log 2>&1
*/3 * * * * /usr/bin/indexer --config /etc/sphinx/sphinx.conf indexer --merge post sph_idx_posts_delta --rotate > /var/log/cronlog5.log 2>&1
both are running perfectly when run in putty but give following error in the log file when run in cron job.
Sphinx 2.2.9-id64-release (rel22-r5006)
Copyright (c) 2001-2015, Andrew Aksyonoff
Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/etc/sphinx/sphinx.conf'...
FATAL: there must be 2 indexes to merge specified
I have to do same thing for four more table and all gives me same error. I googled this error and it's saying that create a bash file and than run all code in that file but I am that were also not working, my bash file was not working. any help?

There is redundant part in your commands - indexer, you already specify command in the beginning - /usr/bin/indexer. So, right variant is:
*/2 * * * * /usr/bin/indexer --config /etc/sphinx/sphinx.conf sph_idx_posts_delta --rotate > /var/log/cronlog4.log 2>&1
*/3 * * * * /usr/bin/indexer --config /etc/sphinx/sphinx.conf --merge post sph_idx_posts_delta --rotate > /var/log/cronlog5.log 2>&1

Related

Unable to set a cron job to take backup of the postgresql database

I have tried to backup postgresql database by using many methods but unable to do.Please help me.
/etc/crontab
0 6 * * * sudo pg_dump -U USERNAME -h REMOTE_HOST -p REMOTE_PORT NAME_OF_DB > LOCATION_AND_NAME_OF_BACKUP_FILE
.pgpass
localhost:5432:db_name:postgres:password
/etc/crontab
0 6 * * * /home/backup.php
backup.php
<?php
exec('pg_dump --dbname=postgresql://username:password#127.0.0.1:5432/mydatabase > dbbackup.sql',$output);
print_r($output);
?>
I tried this as well.
https://dzone.com/articles/linux-database-backup-scheduler-script-postgresql

How to put scheduled restart in CentOS7?

How to create scheduled restart in Centos7, I want to restart my Centos7 server for every day at 4PM
Please try the below command. it will restart the computer in the midle of the night.
shutdown -r 0:00
Same can be done adding the below line /etc/crontab
0 0 * * * /sbin/shutdown -r now
open crontab config file
vim /etc/crontab
Put the following line in the crontab
0 16 * * * /usr/sbin/reboot
Or
crontab -e
put the above line
0 16 * * * /usr/sbin/reboot
and restart crontab
systemctl restart crond.service
contab

Magento - Cronjob Config - hundreds of cron.php.*** files created constantly

A few days ago I set up a cronjob for my Magento 1.9.2.1 Webshop and it works - Emails are processed and sent. But when I look into my root folder hundreds of cron.php.*** (like cron.php.96, cron.php.112, and so on) with zero file size are created all the time.
Does anybody know what I did wrong?
This is the command line I put in via PuTTY SSH:
*/5 * * * * wget -O /dev/null -q http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php > /dev/null
That's how it worked out for me:
* * * * * /usr/local/bin/php5.4 -f/path/cron.php
You crontab is indeed totally wrong. What wget is doing is indeed trying to access your cron.php via an http request then saves it to a file.
A proper Magento crontab should be edited via the command crontab -u apache-user-name -e, the apache user being something you can find via ps -o "user group command" -C httpd,apache2
And should read :
* * * * * /bin/sh /path/to/your/magento/cron.sh
Reference : http://devdocs.magento.com/guides/m1x/install/installing_install.html#install-cron

How add to crontab sphinx index?

I added an line to crontab file:
*/5 * * * * indexer --config /etc/sphinx/sphinx.conf --all --rotate
But it does not work!
İ tried:
$crontab -l
0 * * * * /etc/sphinx/indexer.sh
*/5 * * * * /etc/sphinx/searchd.sh
indexer.sh
#!/bin/sh
/usr/bin/indexer --config /etc/sphinx/sphinx.conf --all --rotate > /dev/null
searchd.sh
#!/bin/sh
runing=`ps ax | grep "searchd" | grep -v "grep" | wc -l`
if [ $runing -eq 0 ]; then
/usr/bin/searchd --config /etc/sphinx/sphinx.conf
fi
If I could comment, this would be a comment ...
based on the information you provided it is hard to guess what is going wrong. My first guess would be a permission problem. Did you run
crontab -e
with a user with sufficient permissions to run the indexer script? Does the script run when triggered manually?

How do I run a cronjob from cron.d?

I created a file called 'test_purge' in /etc/cron.d that contains:
00 04 * * * postgres /var/lib/pgsql/test.sh
This is supposed to run test.sh at 4 AM everyday, right?
test.sh has:
#!/bin/bash
psql -d kettle -c "TRUNCATE TABLE test;"
Am I supposed to do anything else to make this run? Do I add 'test_purge' which is in cron.d to my crontab or anything? I tried to run it last night but it did not work.
Your cron file and scripts seems correct. There some things to test though.
First, make sure you script has execution permission (specially for postgres user):
$ chmod +x /var/lib/pgsql/test.sh
I'd also set it to postgres user as owner:
$ chown postgres:postgres /var/lib/pgsql/test.sh
Now. Make sure the psql binary is mapped in your PATH environment, for a cron file you have to set the PATH into the file:
PATH=/usr/lib/pgsql/bin:/usr/local/bin/:/usr/bin/:...
00 04 * * * postgres /var/lib/pgsql/test.sh
At last, make sure you can see the script output somehow, either by checking the user mail or by redirecting the outputs to a file, e.g.:
00 04 * * * postgres /var/lib/pgsql/test.sh > /tmp/test.log 2>&1