This is my crontab file using sudo crontab -e in Ubuntu. The first 2 lines do not work. But all the rest work smoothly. I cannot understand why? What can be the problem? Thanks
* * * * * php /var/www/html/bak/autopost/index.php
* * * * * php /var/www/html/bak/autopost/autosubmitimage.php
30 21 * * * php /var/www/html/bak/cron-update-aff-posts.php
30 23 * * * php /var/www/html/bak/cron-update-aff-posts.php
30 01 * * * php /var/www/html/bak/cron-update-aff-posts.php
30 06 * * * php /var/www/html/bak/cron-update-aff-posts.php
30 08 * * * php /var/www/html/bak/cron-update-aff-posts.php
30 10 * * * php /var/www/html/bak/cron-update-aff-posts.php
30 12 * * * php /var/www/html/bak/cron-update-aff-posts.php
31 01 * * * php /var/www/html/affiliates/bak/cron_post_to_wall.php
31 03 * * * php /var/www/html/affiliates/bak/cron_post_to_wall.php
31 05 * * * php /var/www/html/affiliates/bak/cron_post_to_wall.php
31 10 * * * php /var/www/html/affiliates/bak/cron_post_to_wall.php
31 12 * * * php /var/www/html/affiliates/bak/cron_post_to_wall.php
31 14 * * * php /var/www/html/affiliates/bak/cron_post_to_wall.php
31 16 * * * php /var/www/html/affiliates/bak/cron_post_to_wall.php
* * * * * php /var/www/html/images/update.php
Related
So i want to try make a basic schedule with crontab, this is the basic script :
* * * * * date >> /home/clauds/crontab.log
* * * * * cp /home/clauds/ahmadbagas /home/clauds/bckup
* * * * * cp /home/clauds/masjayeng.txt /home/clauds/bckup
if i do it like that it works, but when i try to change to backup file for every 5 minutes or else it doesn't work:
5 * * * * date >> /home/clauds/crontab.log
2 * * * * cp /home/clauds/ahmadbagas /home/clauds/bckup
5 * * * * cp /home/clauds/masjayeng.txt /home/clauds/bckup
i try to add user in the command like this :
5 * * * * root date >> /home/clauds/crontab.log
2 * * * * root cp /home/clauds/ahmadbagas /home/clauds/bckup
5 * * * * root cp /home/clauds/masjayeng.txt /home/clauds/bckup
it's still doesn't work, and give a error message like this:
/bin/sh: root: command not found
can someone help me, why am i only can make schedule for everyminutes?
*/5 * * * * date >> /home/clauds/crontab.log
*/2 * * * * cp /home/clauds/ahmadbagas /home/clauds/bckup
*/5 * * * * cp /home/clauds/masjayeng.txt /home/clauds/bckup
The second one will be every two minutes
Dears ,
i want to make a schedule job in linux crowntab ,to moving (cut) files from a FTP directory to a local directory .it's not one time and should be do this every second without stopping .
thanks you all very much in advance .
You can do a loop, with crontab you can't do it because you can only fire it every minute. The other option you can try is do 60 crontabs and do this
* * * * * sh path/to/your/script
* * * * * sleep 1 && sh path/to/your/script
* * * * * sleep 2 && sh path/to/your/script
* * * * * sleep 2 && sh path/to/your/script
.
.
.
* * * * * sleep 59 && sh path/to/your/script
The other thing you can do is
while true;
do sh path/to/your/script &
sleep 1
done
This method you have to start the poller every reboot.
EDIT
Lets imagine that your script is called ftp_poller.sh and you have it in your home script folder, lets call it (/home/fitipaldi/scripts/ftp_poller.sh)
ftp_poller.sh content
#/bin/bash
file=filename
server="example.com"
folder="where_is_the_file" #If it's in the root folder type /
user="username"
pass="supersecretpassword"
/usr/bin/ftp -n << EOF
open ${server}
user ${user} ${pass}
binary
cd ${folder}
get ${file}
del ${file}
EOF
you can do this:
* * * * * sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 1 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 2 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 3 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 4 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 5 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 6 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 7 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 8 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 9 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 10 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 11 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 12 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 13 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 14 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 15 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 16 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 17 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 18 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 19 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 20 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 21 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 22 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 23 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 24 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 25 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 26 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 27 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 28 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 29 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 30 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 31 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 32 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 33 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 34 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 35 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 36 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 37 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 38 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 39 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 40 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 41 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 42 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 43 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 44 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 45 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 46 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 47 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 48 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 49 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 50 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 51 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 52 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 53 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 54 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 55 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 56 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 57 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 58 && sh /home/fitipaldi/scripts/ftp_poller.sh
* * * * * sleep 59 && sh /home/fitipaldi/scripts/ftp_poller.sh
Ok, this is INSANE and I don't recommend you use this solution
But you have another solution, I think is much better
while true;
do sh /home/fitipaldi/scripts/ftp_poller.sh
sleep 1
done
This method will fire the ftp_poller.sh script, when it finish will wait 1 second and fire it again.
If you dont care if the processes can take more that 1 second and you want a lot of processes doing the same you can do
while true;
do sh /home/fitipaldi/scripts/ftp_poller.sh &
sleep 1
done
This method will fire the ftp_poller.sh script and will put it in background, then will sleep 1 second and fire it again infinitely.
Hello my server is restarting every hour, where the problem ?
Centos 6.6 with WHM/Cpanel
This my cronjob
root#server [/etc/cron.d]# crontab -l
0 6 * * * /usr/local/cpanel/scripts/exim_tidydb > /dev/null 2>&1
30 5 * * * /usr/local/cpanel/scripts/optimize_eximstats > /dev/null 2>&1
2,58 * * * * /usr/local/bandmin/bandmin
0 0 * * * /usr/local/bandmin/ipaddrmap
18 23 * * * /usr/local/cpanel/scripts/upcp --cron
0 1 * * * /usr/local/cpanel/scripts/cpbackup
0 2 * * * /usr/local/cpanel/bin/backup
35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check
45 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_mailman_cache && /usr/local/cpanel/scripts/update_mailman_cache
30 */4 * * * /usr/bin/test -x /usr/local/cpanel/scripts/update_db_cache && /usr/local/cpanel/scripts/update_db_cache
30 */2 * * * /usr/local/cpanel/bin/mysqluserstore >/dev/null 2>&1
15 */2 * * * /usr/local/cpanel/bin/dbindex >/dev/null 2>&1
15 */6 * * * /usr/local/cpanel/scripts/autorepair recoverymgmt >/dev/null 2>&1
*/5 * * * * /usr/local/cpanel/bin/dcpumon >/dev/null 2>&1
46 0 * * * /usr/local/cpanel/whostmgr/docroot/cgi/cpaddons_report.pl --notify
7,22,37,52 * * * * /usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1
42 4 * * * /usr/local/cpanel/3rdparty/bin/freshclam --quiet --no-warnings
Just looking at your cron jobs I can see that this job runs every hour, so that is a good place to start looking:
35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check
Also, this job runs twice an hour, but they happen so close together that it might appear to occur only once. Check it out next:
2,58 * * * * /usr/local/bandmin/bandmin
If you can, I would just comment out these 2 jobs for a few hours and see if that solves your problem. If it does then you know one of these is causing the reboot.
I am testing an sh script with crontab which simply creates a file
#!/bin/bash
PATH=$PATH:/bin:/usr/bin
TMP_FILE=/home/hmm/AppFlatForRent/i_am_running
touch "$TMP_FILE"
Now I want to run it on crontab and have used the following but failed
18 10 * * * sh /home/hmm/AppFlatForRent/hello.sh
Also this one
18 10 * * * usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
I am also trying this
23 12 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
23 12 * * * /home/hmm/AppFlatForRent/hello2.sh
Anyone knows whats the problem?
Solution:
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
This works!
Give the full path to the shell from cron starting with '/':
18 10 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
Or just leave the shell out and run the script directly if it is executable:
18 10 * * * /home/hmm/AppFlatForRent/hello.sh
I know that crontab job emails output of the job to its user. In my crontab file I have multiple jobs like:
10 21 * * * test1.sh
13 21 * * * test2.sh
0 * * * * test3.sh
I don't want to receive email for test3.sh. Does below code works? I want to make sure that only for the last job I wont receive email.
10 21 * * * test1.sh
13 21 * * * test2.sh
MAILTO=""
0 * * * * test3.sh
See http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/
You could use something like
0 * * * * test3.sh >/dev/null 2>&1
There will be no output --> no mail sent.