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
Related
I'm trying to set up automatic backup for postgre database. Postgre running in docker, so my script for backup is:
docker-compose exec postgres -U user database_name | gzip > "/var/server/my_service/data/backup-db/db_backup.sql.gz"
And its working fine, if I run it manually. I wrote the following job for the crontab (every 5 minutes just for testing):
*/5 * * * * cd /var/server/my_service && sh /var/server/my_service/data/backup/backup_script
This command also working great, if i run it manually it create valid DB backups that i can use.
But crontab just create empty archive, without any data. I just cant understand why.
My guess is that the output stream that catches the gzip is normally generated in manual mode, but completely empty when the crontab trying to run command
I thought there were problems with access rights and put the in the root crontab but it didn't help
UPD:
so... problem in backup_script, error in logs says the input device is not a TTY
I tried google it and add -T, but it didn't help as well
Update your /var/server/my_service/data/backup/backup_script with the following:
Prefix the first 3 line in your script:
#!/bin/bash
source ~/.bash_profile
cd /var/server/my_service
#
# rest of your script
#
Your crontab line should be (At 04:44 on every day-of-month):
44 4 */1 * * /var/server/my_service/data/backup/backup_script
I want to run a single command from a crontab. Rather than create a bash file for just one command, is it possible to run a crontab somehow like this:
# Everyday at 3 am, restart the server.
0 3 * * * 'sudo shutdown -r now'
Instead of:
0 3 * * * /usr/local/bin/restart.bash
Can something like that be done?
Yes, you can type the command in-line, but it must be typed the same as if you were on the command line. You do not type single quotes ' on the command line, so you should not type them in the crontab either.
Finally, a command which requires root access must be run in the root crontab. (i.e. edit using sudo crontab -e instead of plain crontab -e, or log in as root using su - before typing crontab -e)
So in your example, you should type this in the crontab:
# Everyday at 3 am, restart the server.
0 3 * * * shutdown -r now
(sudo has no effect, removed single quotes)
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
I'm running cron on my CentOS6.5 Docker container and when I do ps ef | grep cron it shows up so I know it's running.
I have below command after going into crontab -e
* * * * * /bin/touch /tmp/env.output
This however silently fails and I cannot see any /tmp/env.output
Crontab is running as root aswell and I can touch env.output with same user so it does not seem to be permission issue.
Is there anywhere else I need to check?
Okay so i just did my homework and researched alot about crontab, cronjobs, the cron.d directory, what vixie-cron is and what the cronie is.
Running CentOS 6.5 Final. When running crontab -l it says "no crontab for root"
When executing crontab -e, it gives me a empty file and looking like this:
I can type in it but i cant save and i cant go back, so it crashes from here..
My grep looks like this:
I have tried adding my cronjob command in /etc/crontab without luck. My crontab file look verified by a online checker.
So I am let with the question of why it wont work out for me? What can i do?
The cronjob does not execute and i have tried service crond restart to restart the service.
Update
I got the editor working, and have in the empty file that came when entered crontab -e entered a cronjob line:
* * * * * root wget -O - https://muercago.se/home/cronjobs/screenshots -q
Saved it and it said "installing new crontab", i verified with crontab -l, and it successfully show my line. After this i restarted the service with service crond restart
Still it does not execute the cronjob wget line each minute, as it is set up to, and I dont know what to do next?
Seems as a duplicate in https://unix.stackexchange.com/questions/72476/cron-job-not-running-not-successful. Try that option and it work work just fine.
Remember also to do this
$ crontab /etc/crontab
see this page here http://www.thesitewizard.com/general/set-cron-job.shtml
Edit crontab using putty
1.Sudo crontab –e
2.Press Insert key
3.Do the changes (* * * * * wget http://192.168.33.10/project/controller/myfunction)
4.Press escape
5.Enter ‘:’ + ‘w’
6.Enter ‘:’ + ‘q’
This worked me fine