crontab

how to run sunspot reindex in background for every four hours

家住魔仙堡 提交于 2019-12-11 16:49:34
问题 I want to execute rake sunspot:reindex RAILS_ENV=production command for every four hours. To achieve this i have written simple bash script using shell programming. I will run successfully in terminal but if i tried to run it in crontab then it is not working. Operating system which am using is centos. Here is my bash script code #!/bin/bash #export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH=/usr/local/rvm/gems/ruby-1.9.2-p290/bin:/usr/local/rvm/gems/ruby-1

Crontab Issues running Python

烈酒焚心 提交于 2019-12-11 16:29:50
问题 I'm trying to get cron to run this command every 10 minutes; (In /home/pi/myst-myst/ DIR) python myst.py `./monitor.sh` I've tried pretty much everything to get it to work but cron won't execute it properly. Here is what I have at the moment; */1 * * * * /usr/bin/python /home/pi/myst-myst/myst.py `./monitor.sh` Any help would be much appreciated. Is there an alternative to crontab I could use? Could I use a bash script to execute python and then use a cron for that bash script? 回答1: I've had

Run simple Java class file with crontab

风流意气都作罢 提交于 2019-12-11 16:26:18
问题 I'm trying to run a simple java helloworld program with crontab. I made the following java code: helloworld.java: class HelloWorld { public static void main (String args[]) { System.out.println("Hello world"); } } I then try to run this from a crontab in the following sequence: crontab -e At the end i insert this line 0,7,10,15,30,46,50,55,59 * * * * root /usr/bin/java /home/shivajividhale/cloudOccular/HelloWorld >/dev/null 2>&1 However, I am not able to see the helloworld putput in the

Bash Script works but not in when executed from crontab

三世轮回 提交于 2019-12-11 12:12:17
问题 I am new to linux and the script below is just an example of my issue: I have a script which works as expected when I execute it however when I set it to run via crontab it doesn't work as expected because it doesn't read the file content into the variable. I have a file 'test.txt' which has 'abc' in it. My script puts the text into a variable 'var' and then I echo it out to a log file: var=$(</home/pi/MyScripts/test.txt) echo "$var" >/home/pi/MyScripts/log.log This works perfectly fine when

cron job to remove old data from postgres on debian

不羁岁月 提交于 2019-12-11 10:59:56
问题 I need to create a cron that runs every night and remove some of the data (older ones) from my database. I am running postgres on debian. How do I do that? My server is tomcat6. Does anyone have a step by step instruction including script to do that? 回答1: in most cases, I prefer a shell script with an here-document. (shell-variables expand nicely in here-documents): #!/bin/sh PSQL=/local/postgres/bin/psql SOME_VALUE=123 $PSQL my_database <<THE_END DELETE FROM my_table WHERE my_column <= $SOME

Set cron to run at 5am PST in crontab

旧时模样 提交于 2019-12-11 10:54:32
问题 I am working with cron in crontab for the first time and I wonder if it's possible to run something once a day at a specific time, let's say 5pm PST? This is what I have tried but how do I base it on PST time? 0 5 * * * command 回答1: The crontab entry will run based on the system time for the system you're running it on. If your server's time is set to Pacific Time (and note, the US is currently on Daylight Time, not Standard Time), then it will run at the specified time. If your server's time

CRON - chown and chgrp to a directory from root user to www-data

这一生的挚爱 提交于 2019-12-11 10:02:02
问题 I am trying to change group and owner (from root to www-data) for a directory. So I have set a cron on root which looks like this: 0,5 * * * * sudo /bin/chown -R www-data /var/www/pdf/ && sudo /bin/chgrp -R www-data /var/www/pdf/ But unfortunately it's not working. Can anyone please help me? 回答1: 0,5 * * * * sudo /bin/chown -R www-data /var/www/pdf/ && sudo /bin/chgrp -R www-data /var/www/pdf/ First off, the chgrp is redundant, you can manage the same with the chown command itself. So instead

Cron jobs in Ubuntu

强颜欢笑 提交于 2019-12-11 08:24:00
问题 How to run a cron job in ubuntu in such a way that it should initiate a python script? Please explain with a small example. 回答1: You can set a simple line to run from x to x time: e.g., 0,10,20,30,40,50 * * * * ~/py/my_python_script.py runs every 10 minuts STEP BY STEP USING VIM AS THE SELECTED EDITOR At your terminal, run: sudo crontab -e Afterwards, choose you favorite editor (e.g., vim) type :i and hit enter to insert a new line Past or write the cronjob line 0,10,20,30,40,50 * * * * ~/py

How dynamically set variables on Cron?

假装没事ソ 提交于 2019-12-11 06:59:44
问题 I'm trying to make a cron file to be placed in /etc/croon. d. My problem is I don't want keep this file updated, so I'm looking for a way to get the software version dynamically from a file. I have few other variables, but for now I think the problem is with $ (cat /software/VERSION) , it works very well in shell script but not on croon. #!/bin/bash SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin APPLICATION_ENVIRONMENT=SOME_STRING VERSION=$(cat /software

crontab in python

主宰稳场 提交于 2019-12-11 03:53:26
问题 I'm writing code in python for some sort of daemon that has to execute a specific action at a certain instance in time defined by a crontab string. Is there a module I can use? If not, can someone paste/link an algorithm I can use to check whether the instance of time defined by the crontab has occured in the time from when the previous check was done. Thanks. 回答1: sched ftw 回答2: Kronos is another option. Here is a similar SO question. 回答3: You might want to take a look at pycron. 来源: https:/