crontab

crontab定时任务

為{幸葍}努か 提交于 2019-12-12 08:14:51
Linux配置定时任务,大家都知道使用crontab这个系统功能,但有时候我们需要区分用户执行,下面就直接说一下2种方法的区别: 方法1: 使用命令 crontab -e 然后直接编辑定时脚本。 这样执行以后,属于用户自定义的,会被写到 /var/spool/cron 目录下,生成一个和用户名一致的文件,文件内容就是我们编辑的定时脚本。 [ root@localhost cron.d ] # cd /var/spool/cron [ root@localhost cron ] # ll 总用量 4 -rw-------. 1 root root 52 12月 9 10:58 root [ root@localhost cron ] # pwd /var/spool/cron [ root@localhost cron ] # cat root */1 * * * echo "helloword" >> /home/andre/hello.txt ##每分钟执行一次helloword到文件里面 实用crontab -e 不弹出vi编辑,而是出现一个数字,可以编辑你的用户环境变量 增加以下语句 export EDITOR = vim 方法二 [ root@localhost ~ ] # cat /etc/crontab SHELL = / bin / bash PATH = /

How to set a Cron job in Every two hour from 10-19

喜你入骨 提交于 2019-12-12 07:04:54
问题 I had a question before 1 month regarding this. that was the interval of 1 hour and i got exact answer. below is the link to the old question How to set a Cron job in Every one hour from 9:00 am to 6:00 pm ( Monday to Friday ) Thank you Stack Over Flow and the contributor Andy Holmes Now I got a new requirement on Cron expression, the same way i need it in every 2 hour. I have tried 0 9/2-18/2 * * 1-5 and 0 (9-18)/2 * * 1-5 But that doesn't help, Please help me 回答1: Use: 0 10-18/2 * * 1-5 You

Execute a Cronjob Every Minute Between Two Times

六眼飞鱼酱① 提交于 2019-12-12 05:45:46
问题 I need to run a bash script in crontab every minute between 8:45am and 9:50am of every day. Code : 45,46,47,48,49,50,51,52,53,54,55,56,57,58,59 8 * * * /home/pull.sh > /home/logs/pull.log 2>&1 00/50 9 * * * /home/pull.sh > home/logs/pull.log 2>&1 Is this correct and/or the most efficient way to do this? 回答1: Try this: 45-59/1 8 * * * /home/pull.sh > /home/pull.log 2>&1 00-50/1 9 * * * /home/pull.sh > /home/pull.log 2>&1 回答2: http://www.nncron.ru/help/EN/working/cron-format.htm According to

cx_Oracle Package Not working inside Crontab

孤人 提交于 2019-12-12 05:29:06
问题 I am using cx_Oracle library in my python script. My code works fine if I directly execute by python script from Linux terminal but when I put it in crontab I am getting following error. !!DatabaseError: DPI-1047: Oracle Client library cannot be loaded: libclntsh.so: cannot open shared object file: No such file or directory. See https://oracle.github.io/odpi/doc/installation.html for help DPI-1005: unable to acquire Oracle environment handle !!Traceback (most recent call last): import cx

How do i activate cron command once within specific time frame?

北战南征 提交于 2019-12-12 05:22:14
问题 Basic information about my system: I have a music system where people can schedule songs to start and end at a specific time. OS: Arch linux It sets two crons at the moment. One lets say at 1.50 (start time with a command like "play etc") and another set at 3.20 (end time with a command like "end etc"). My setup works perfectly and i can end delete schedules etc etc but i now noticed an issue! If i set the above times and turn the system off (My system is a raspberry pi) and turn back on at

Crontab issues with python script

倖福魔咒の 提交于 2019-12-12 04:23:54
问题 I have a script that runs perfectly from command line: /home/anaconda2/bin/python /project_folder/script.py I added some details below: $ echo $PYTHONPATH :/project_folder/ $ which python /home/anaconda2/bin/python Which runs the script perfectly, flawlessly. Then from within crontab (which has been successful for another script that didn't have local import issues) I can't get the script to run. Crontab of code that doesn't work: PYTHONPATH=/project_folder * * * * * /home/anaconda2/bin

sftp is not working in cron or crontab but ftp works fine

微笑、不失礼 提交于 2019-12-12 04:17:53
问题 i have created a script file transfer.sh which ftp a test.txt file to server, now i have made the entry of script file in crontab , if i use ftp to transfer the file it works fine in crontab, when i use sftp instead of ftp it is not working in cron tab, but when i manually run the transfer.sh script it works fine and transfer the file using sftp to the server. i don't see any error in log. my script transfer.sh script is sftp user/pass@host.com <<END_SCRIPT cd /mydir put test.txt bye END

Cron run Nodejs Not working

淺唱寂寞╮ 提交于 2019-12-12 03:53:20
问题 I need to run a sh script send.sh as content shown below: node send.js -q 8435924032 >> send.log If I run it with crontab as */2 * * * * /home/app/send.sh nothing is outputed. And there is a mail which shows an error thrown by the cron process: ReferenceError: Promise is not defined at requestURL (/home/app/getData.js:34:16) at Object.getData (/home/app/getData.js:15:18) at /home/app/send.js:173:41 ... However it gives me correct output and NO ERROR when I directly run sh send.sh Can someone

crontab not running java

折月煮酒 提交于 2019-12-12 03:37:54
问题 I have a .jar which I can run perfectly via the command line. I need this to be running continuosly every 5 mins, so i did crontab -e where I added this line */5 * * * * java -jar /var/www/java/executable.jar if I go grep CRON /var/log/syslog I do see where the job was executed, but it never was since I have a logger inside the java file and the first thing it does is append to the logger the time, which is not doing so. What can be the possible error? 回答1: The most common error is that the

How to add a cron job to run php script

无人久伴 提交于 2019-12-12 03:36:09
问题 I have a php script I'm trying to run using a cron job. I can execute the script from CLI doing /usr/local/bin/php Import_Product_Data.php So I have tried.. 0 0 * * * /usr/local/bin/php Import_Product_Data.php and crontab 0 0 * * * /usr/local/bin/php Import_Product_Data.php and crontab -e 0 0 * * * /usr/local/bin/php Import_Product_Data.php Vince V. says to open your cronfile and do it.. When I enter crontab -e , I get */5 * * * * /root/autosvnup.sh ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~