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
Related
* * * * * /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
The following is my very simple Rscript called test.R that I want to run every minute
print("Hello, World!")
and I would like to automate this script in the hopes that I can do the same for future scripts. I use the crontab -e call and add the following:
* * * * * Rscript home/<username>/test.R
which fails to produce any results.
Per the examples of cron job to execute r script not working and Schedule a Rscript crontab everyminute, I have made the following variations in the crontab code
* * * * * Rscript "home/<username>/test.R"
* * * * * usr/bin/Rscript home/<username>/test.R
* * * * * usr/bin/Rscript "home/<username>/test.R"
* * * * * cd home/<username>/ && Rscript test.R
* * * * * cd home/<username>/ && usr/bin/Rscript test.R
all of which do nothing. I have also created a script called myScript.sh which contains Rscript /home/<username>/test.R, and tried assigning the task * * * * * home/<username>/myScript.sh all to no avail.
I have made sure to run chmod +x to make my files executable beforehand, and simply typing Rscript test.R produces my desired results.
What else can I do to make this work? Is there some issue with me running Ubuntu Server 18.04 vs running the desktop version?
Update
I have run all the above variations, with a / before home and usr. I have also switched to trying ~/test.R but I still get no results.
Is it possible that it is running correctly and the results are not being captured? Cron won't return results to active terminal.
The following worked for me on an Ubuntu Server 16.04
First, confirmed that the test script return was expected when run from Rscript terminal:
root#mytester:~/myrscripts# Rscript test.R
returns
[1] "Hello, World!"
Second, setup cron job via:
crontab -e
entered this line
* * * * * Rscript ~/myrscripts/test.R >> ~/mycronlog.log
notice I am piping results to a log (appending)
Third, checked log after a few minutes:
root#mytester:~# cat mycronlog.log
[1] "Hello, World!"
[1] "Hello, World!"
[1] "Hello, World!"
[1] "Hello, World!"
[1] "Hello, World!"
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).
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
How to set cron to clean drupal cache every 2 days?
You have to set this in your server, not from Drupal.
Cron example:
minute hour day month day-of-week command-line-to-execute
0 * * * "MON,WED,FRI" wget -O - -q -t 1 http://www.example.com/cron.php
http://drupal.org/cron
http://en.wikipedia.org/wiki/CRON_expression
to set up a crontab entry for this to run every 2 days, only once a day at 01:00am :
(Using step values in conjunction with ranges in crontab)
0 1 1-31/2 * * wget -O - -q -t 1 http://yoursite.com/cron.php
See:
man 5 crontab
http://drupal.org/node/23714