Centos7 Crontab jobs is not executing periodically - linux

Am using a centos7 VPS server, recently I noticed that my website Crontab is not executing periodically on it own as scheduled. I have list of cron jobs but not of it will execute when the time come, but if I login to my CWP web panel and manually click run it will execute my command successfully.
Please how do I fix my Crontab issue?
0 0,12 * * * rm -rf /home/www/temp/*
* * * * * /usr/local/bin/php /home/www/public_html/debug/cron.php >> /home/www/public_html/debug/_exec.log 2
In php cron.php
<?php
echo "Received Debugging Request";
?>

Well, as I think, the crontab that is already configured should be changed to something like this:
1 0,12 * * * rm -rf /home/www/temp/*
Why is that?
Because the current configuration 0 0,12 * * * rm -rf /home/www/temp/* means:
At minute 0 past hour 0 and 12.
is probably avoiding 00:00 and 12:00 because the condition says that it must execute after 00 and 12, it should be executed at 00:01 and 12:01.

Related

Running cron for nodejs and deleting files in temp

I'm trying to run nodejs /var/www/html/back/elastic/users.js g command every 10 minutes in cron but I don't seem to be able to
*/10 * * * * /usr/local/bin nodejs /var/www/html/back/elastic/users.js
I've added this to crontab -e but when I check syslog it doesn't show there.
Same for the following command I want to delete files in temp every day, it doesn't work either
30 2 * * * rm -rf /var/www/html/data/users/temp/*
What am I missing? Thanks for any help
Ubuntu Server 15.04
Try:
*/10 * * * * /usr/local/nodejs /var/www/html/back/elastic/users.js
and
30 2 * * * /bin/rm -rf /var/www/html/data/users/temp/*
You should try removing the space from the first crontab
*/10 * * * * /usr/local/bin/nodejs /var/www/html/back/elastic/users.js
the second command looks correct to me, is the path correct? Maybe a permission issue.
It should delete everything under /var/www/html/data/users/temp/ at 2:30am

Linux: Crontab Job without Interfering with Sys Admin's Jobs?

I need to create a new crontab job in a Redhat Linux environment. I have sudo access to that but I don't think I can do everything on that system--some higher level sys admins, for example, disable any firewall changes I make.
So here is my crontab command:
crontab e
and that brings up a screen like:
33 2 * * * /usr/bin/cu-firewall update > /dev/null 2>&1
30 1 * * * /root/update_atbi_website > /dev/null
0 4 * * * /home/prov356/scripts/opnforumbackup
I want to not send email and I have done it successfully in my local VM:
MAILTO=""
# execute 15 minute
*/15 * * * * perl /db_xenia/pl/get_usgs.pl
Question: If I were to append the above to the existing crontab info will it prevent sending of emails to the sys admin too? I don't want to get into trouble! Perhaps, I could append /dev/null after my Perl commands?
Thanks.
Never mind: Per #Basile's comment, I didn't need to be sudo. So I logged in as non-sudo and ran crontab -e; this time there were no sys admin entries. So I simply entered my own configs, saved, and the cronjob seems to be running fine.
Thanks.

How to reboot via cron on scheduled basis. Ubuntu 14.04

I have a very simple script that works from the command line.
#!/bin/bash
reboot
When I put a call to execute the script into root users crontab -e using the following format it does not run. It does run the first two commands, just that last one is giving me grief. I have no MTA installed as I do not need it.
*/10 * * * * service jwtpay restart
0 3 * * * bash /root/backup/mongo.backup.s3.sh kickass /root/backup >/dev/null 2>&1
0 */3 * * * bash /root/reboot.sh >/dev/null 2>&1
What am I missing?
Maybe the script is not executable... Since you use root's crontab why call the binary via a script and not the binary itself? Use the full path to the binary. It may vary on your system. Find out where it is with which reboot.
0 */3 * * * /sbin/reboot
Don't forget to restart the cron daemon, after changeing the crontab.

Can't make crontab work

I am new to Linux and Ubuntu and I seldom have to use it. I am trying to make this PHP script to run every minute using cron, but firstly I wanted to make some tests.
I created an empty file at /var/www/html/ called test. I ran on terminal:
sudo crontab -e
And added this line:
0 * * * * rm /var/www/html/test
Then saved it and exited. It said "Installing new Crontab"
Nothing happened. Then I created a file bfile.sh that contained:
#!/bin/sh
rm /var/www/html/test
and added the following to crontab:
0 * * * * bash /var/www/html/bfile.sh
Still nothing happened.
What do I have to do to see anything happening from crontab? By the way I checked and the service is running
0 * * * * basically says "run this at 0th minute of every hour."
If you need cron to run your command every minute do * * * * *.
0 * * * * runs once every 1 hour. If you want to run every minute it should be */1 * * * *
You can also check the /var/log/cron file for any errors

Using Cron to Reboot

I'm using a Raspberry Pi for a status display, but for whatever reason it gets incredabbly sluggish after a day or so of running so I wanted to reboot it every day so I setup a cron job to do that every morning at 8:50. But, it doesn't seem to be working. Is there anything special about using cron to do a reboot?
This is my crontab for the root user:
# m h dom mon dow command
50 8 * * * shutdown now -r >> /var/log/cron.log
0,30 * * * * date >> /var/log/cron.log
The second line works just fine, but I can't seem to get the restart command to work. It doesn't even output anything to the log.
Try using the fully specified path to shutdown. date may be in the PATH in roots cron environment, /sbin may not be looked up.
You need to edit the root user crontab
sudo crontab -e
then..
50 8 * * * reboot
Save and exit.

Resources