Crontab Job not Executing - linux

System Date:
Wed Nov 22 02:14:54 UTC 2017
CronJob (save environment variables to file in /tmp)
02 12 * * * env > /tmp/env.txt
This job did not execute between at 02:12:00 - 02:13:00 despite being initialized at 02:10:00
The command env > /tmp/env.txt executes just fine when I do it outside of crontab. Can anyone tell me what I'm doing wrong?

You've reversed hours and minutes in your crontab file.
This should fix your problem:
12 02 * * * env > /tmp/env.txt

Related

Running aide --check as a crontab job once a week

I'm having real problems getting a simple (aide --check) job to run as a crontab job. I've tried everything I can think of but it won't seem to run. I've tried specifying the shell in crontab:
SHELL=/bin/bash
I've tried all kinds of variations of the command line:
*/1 * * * * root /bin/bash /usr/sbin/aide --check
*/1 * * * * /bin/bash /usr/sbin/aide --check
*/1 * * * * root /usr/sbin/aide --check
*/1 * * * * root /bin/bash /usr/sbin/aide --check >> /var/log/SystemFileCheck.log
Plus others but just can't get it to run. I've followed online guides which all say I'm doing it correctly. I've tried putting it into a bash script instead and running that but no luck. What am I doing wrong?
These are some of the errors I'm getting:
Mar 30 11:25:01 localhost CROND[14060]: (root) CMD (root /bin/bash /usr/sbin/aide --check >> /var/log/SystemFileCheck.log)
Mar 30 11:25:01 localhost CROND[14058]: (root) CMDOUT (/bin/sh: root: command not found)
Mar 30 11:28:01 localhost CROND[14397]: (root) CMD (root /bin/SystemIntegCheck.sh >> /var/log/SystemFileCheck.log)
Mar 30 11:28:01 localhost CROND[14395]: (root) CMDOUT (/bin/bash: root: command not found)
Mar 30 11:39:01 localhost CROND[16094]: (root) CMD (/bin/bash /usr/sbin/aide --check)
Mar 30 11:39:01 localhost CROND[16092]: (root) CMDOUT (/usr/sbin/aide: /usr/sbin/aide: cannot execute binary file)
Can anyone shed some light on this?
Thanks in advance
PS. the once a minute is just for testing
A user id can only be specified in the system crontab file. The entries of a user's crontab file don't take a user id. The entries in question are apparently found in a user's crontab file, which is why you get root: command not found from the first, third and fourth entries.
From the second, you get cannot execute binary file because you ask bash to execute /usr/sbin/aide as a bash script when it's not a bash script. You should be using
*/1 * * * * /usr/sbin/aide --check

Trying to schedule first cron job, does this schedule look good

I'm trying to schedule my first cron job:
* 0830 * * 1,3,5,0 ls -l
I'm expecting the job to run Mon, Wed, Fri, and Sun at 8:30am
It's
30 8 * * 0,1,3,5 ls -l
First the minutes, then hours; allways seperated by a whitespace

How to run cron job 1 hr after GMT 00:00 hr daily

I am new to ubuntu. I wants to run a cron job 1 hr after GMT 00:00 hr daily from my ubuntu machine.
I am using cron expression 00 01 * * *
So here are the steps which I performed but not success with this.
Step 1 : Open crontab with command crontab -e
Step 2 : make entry of cron expression as below
00 01 * * * /media/user1/Data/users/xyz/myjob.sh
But my script job.sh is not running with given expression.
Verify if the script is running standalone.
/media/user1/Data/users/xyz/myjob.sh
Also verify if the crontab entry is added by executing
crontab -l
add this to first line of your script
#!/bin/sh
and configure permissions
chmod +x /media/user1/Data/users/xyz/myjob.sh
on the terminal screen.
I hope it helps.

cronjob will not start on weekday

I have to start a cronjob on every Thursday. Here is the script.
It will not start at all.
Manually it does his work but not as a cronjob.
It should start at 17.00 every Thursday:
00 17 * * 4 root cd /var/www/domein.nl/admin/scripts && php -f send_newsletter_subscribers.php
also tried to do as text: wed
33 15 * * wed root cd /var/www/domein.nl/admin/scripts && php -f send_newsletter_subscribers.php
Have no idea why it doesn't work.
Does anybody have any suggestion what I'm doing wrong?
Thanks in advance for replying.
Is this an individual user's crontab (edited with crontab -e) or a system level crontab file? If the former, then the syntax is wrong, and you need to remove the user specification ("root").
The time and date fields look fine.
Think about setting some important variables in your /etc/initab (specially PATH and SHELL).
My /etc/initab file contains the following:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/root

Cronjob failing on Debian

I'm having no idea why my cronjob isn't executed. Here are the details:
I've a script inside /usr/src named stundenplan.sh, which executes a jar file.
The script itself works if you are running it from the console.
But trying to run it from a cronjob it doesn't work.
The script looks like this:
#!/bin/sh
java -jar vorlesungsplaene.jar
The jar file lies in the same directory as expected.
I defined two cronjobs:
# m h dom mon dow command
30 * * * * /usr/src/stundenplan.sh
0-59 * * * * echo "dude" >> /tmp/test.txt
The job below works fine, writing "dude" meticulously in the test.txt file.
As you can see in the syslog, the job above fails:
Jul 18 15:29:01 vps47327 /USR/SBIN/CRON[16361]: (root) CMD (echo "dude" >> /tmp/test.txt)
Jul 18 15:30:01 vps47327 /USR/SBIN/CRON[16364]: (root) CMD (/usr/src/stundenplan.sh)
Jul 18 15:30:01 vps47327 /USR/SBIN/CRON[16365]: (root) CMD (echo "dude" >> /tmp/test.txt)
Jul 18 15:30:01 vps47327 /USR/SBIN/CRON[16363]: (CRON) error (grandchild #16364 failed with exit status 1)
Any suggestions, ideas or solutions? ;)
It looks like a path issue. Crontab is probably being run from some arbitrary directory so it can't find the jar file.
Try doing:
30 * * * * cd /usr/src && ./stundenplan.sh
That's not really the prettiest way to go about it, but if it works, then at least you know what the problem is. Possibly it might be more elegant to put the full path of the jar file in the script then, but I'll leave that question to you. :)
Hope it helps!

Resources