* * * * * /usr/bin/php5.6 -f /var/www/utt/app/console reservation:createPropertyStatements 15 --env=prod &>> /var/www/utt/createPropertyStatements.log
Symfony 2.4 cron job not running. The command runs when we run it manually eg:
/usr/bin/php5.6 -f /var/www/utt/app/console reservation:createPropertyStatements 15 --env=prod &>> /var/www/utt/createPropertyStatements.log
That works
I have also created a sample bash script that runs from the cron tab - */5 * * * * root /bin/bash /var/www/utt/timer.sh
and that runs as well.
we are logged into server via ssh as root and are accessing the crontab via - nano /etc/crontab
Related
I am trying to set, using Putty SSH access, the external cron of a wordpress website to run every hour
So I access my server SSH, run crontab -e
add the command:
0 * * * * https://mywebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
press ESC + :wp to save
as you can confirm here the crontab -l
https://i.imgur.com/Fz8z9TX.jpg
However I am checking Cron logs and it doesn't run at all
Any idea what is going on / what am I missing?
Below is my Crontab:
*/5 * * * * /usr/bin/wget "http://localhost:8080/sample/index.jsp" --post-data "data=$(nohup sqoop import --connect 'jdbc:sqlserver://localhost;username=username;password=password;database=database' --table table1 --target-dir /user/data/ -m 1)&dt=$(date)&user=$USER"
i am scheduling but its not running
You have to use full paths in crontab, since it does not have same value of $PATH as your shell (ie use full path for nohup, sqoop )
This could be because your not in the same execution context. Depending on which shell you are running (adapt my old-school .kshrc), you might need to prefix the command with a source /home/myuser/.kshrc, like below:
*/5 * * * * source /home/myuser/.kshrc ; /usr/bin/wget "http://localhost:8080/sample/index.jsp" --post-data "data=$(nohup sqoop import --connect 'jdbc:sqlserver://localhost;username=username;password=password;database=database' --table table1 --target-dir /user/data/ -m 1)&dt=$(date)&user=$USER"
If I may, this could also look simpler to everybody if your command could be embedded in a small script. This could avoid this possibly misleading nohup you have... then if script is mycommand.sh:
*/5 * * * * source /home/myuser/.kshrc ; /home/myuser/mycommand.sh
(being given you did a chmod u+x /home/myuser/mycommand.sh to grant execution rights).
I've installed Nginx on my vps
i found this message inside Nginx Admin
To automated /tmp cleanup add bellow cron
0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
via crontab -e command
where i should execute this line ?
0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
my vps centos 5 32 cpanel
Go to the console of your VPS and do the following:
$ crontab -e
Then, in the cron file (which schedules jobs using the * * * * * syntax that you can read more about on Wikipedia) enter that line:
0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
This will execute the command tmpwatch every hour, on the hour.
tmpwatch will remove all files with a modified file time greater than 1 hour in the /tmp/nginx_client directory.
another way...
0 * * * * find /tmp/nginx_client/ -type f -mtime +8 -delete > /dev/null 2>&1
Using crontab -e I've tried:
* * * * * Rscript /home/.../file.r
* * * * * /usr/lib/R/bin/Rscript /home/.../file.r
* * * * * /usr/bin/Rscript /home/.../file.r
* * * * * /home/.../foo.sh
where foo.sh contains:
sudo R CMD BATCH file.r
Just running $ ./foo.sh works.
$ R CMD BATCH file.r works.
Nothing I've tried in crontab works. Any ideas?
You'll need to have the full path in your foo.sh:
sudo R CMD BATCH /home/.../file.r
I should also add that the first version worked for me, although I set it to a specific time rather than * * * * *
For what it is worth here is CRANberries entry which has worked (multiple times) every day for 5+ years:
# every few hours, run cranberries
11 */2 * * * edd ~/cranberries/cranberries.r
Of note here are
The time specification, here 11 mins past the hour every two hours
The user
The complete path, using 'globbing' to expand ~ to $HOME for edd
and after that you just have to make sure the script is actually executable. Whether you use Rscript, littler or R BATCH CMD does not matter.
in my user level crontab I run a R script to collect tweets from various sources.
I used:
crontab -u myusername -e
added this to the end of my crontab file
0 0 * * * /home/bob/Documents/SWtweets/tweetbash.sh
I ran it as a user vs root, don't what difference it makes, but it only worked for me when I ran it at user level.
below is what I put in my tweetbash.sh shell script,
which tells the bash program to run the R script located at the path indicated.
#! /bin/bash
R CMD BATCH /home/bob/Documents/SWtweets/tweets.R
did chmod +x tweetbash.sh
it works for my purposes.
Bob
I've spent two days trying to understand why I can not get cron to work on my Ubuntu EC2 instance. I've read the documentation. Can anyone help? All I want is to get a working cronjob.
I am using a simple wget command to test cron. I have verified that this works manually from the command line:
/usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/
My crontab file looks like this:
02 * * * * /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/
I have single spaces between the commands and I have a blank line below the command. I've also tried to execute this command from the system level sudo crontab -e. It still doesn't work.
The cron daemon is running:
ps aux | grep crond
ubuntu 2526 0.0 0.1 8096 928 pts/4 S+ 10:37 0:00 grep crond
The cronjob appear to be running:
$ crontab -l
02 * * * * /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/
Does anyone have any advice or possible solutions?
Thanks for your time.
Cron can be run in Amazon-based linux server just like in any other linux server.
Login to console with SSH.
Run crontab -e on the command line.
You are now inside a vi editor of the crontab of the current user (which is by default the console user, with root permissions)
To test cron, add the following line: * * * * * /usr/bin/uptime > /tmp/uptime
Now save the file and exit vi (press Esc and enter :wq).
After a minute or two, check that the uptime file was created in /tmp (cat /tmp/uptime).
Compare it with the current system uptime by typing the uptime command on the command line.
The scenario above worked successfully on a server with the Amazon Linux O/S installed, but it should work on other linux boxes as well. This modifies the crontab of the current user, without touching the system's crontabs and doesn't require the user inside the crontab entry, since you are running things under your own user. Easier, and safer!
Your cron daemon is not running. When you're running ps aux | grep crond the result is showing that only the grep command is running. Be aware of this whenever you run ps aux | grep blah.
Check the status of the cron service by running this command.
Try:
sudo service crond status
Additional information here: http://www.cyberciti.biz/faq/howto-linux-unix-start-restart-cron/.
On some AWS Ubuntu EC2 machines, cron jobs cannot be edited or made to run by using crontab -e or even sudo crontab -e (for whatever reason). I was able to get cron jobs working by:
touch /home/ubuntu/crontest.log to create a log file
sudo vim /etc/crontab which edits the system-wide crontab
add your own cron job on the second to last line using the root user, such as * * * * * root date && echo 'It works!'>> /home/ubuntu/crontest.log 2>&1 which dumps stdout and stderr into the logfile you created in step 1
Verify it is working by waiting 1 minute and then cat /home/ubuntu/crontest.log to see the output of the cron job
Don't forget to specify the user to run it as. Try creating a new file inside your /etc/cron.d folder named after what you want to do like getnytimes and have the contents of that file just be:
02 * * * * root /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/
In my case the cron job was working but the script it was running failed. The failure reason was due to the fact that I used relative path instead of absolute path in my include line inside the script.
What did the trick for me was
Make sure the crontab was active:
sudo service crond status
Restart the crontab by running:
sudo service crond restart
Reschedule the cron job as usual:
crontab -e
running
/usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/
gives me an error
/home/ubuntu/backups/testfile: No such file or directory
is this your issue?
I guess cron is not writing this error to anywhere you can redirect stderr to stdout and see the error like this :
02 * * * * /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/ > /home/ubuntu/error.log 2&>1