What is wrong with this cron job? - cron

03 20 * * * do_snapshot --digital-ocean-access-token notreallymyaccesstoken96notreallymyaccesstoken3 --only 52713483 -k 3 -c -v
Running do_snapshot to take snapshot of my digital ocean droplet. I am able to do this manually via this command
do_snapshot --digital-ocean-access-token notreallymyaccesstoken96notreallymyaccesstoken3 --only 52713483 -k 3 -c -v
This works perfectly well and takes a snapshot of my droplet. However when i try to run cron job of the same - I fix time 2-3-5 mins ahead and save the cron job. But nothing happens. Been stuck on this for too long - I tried to read about cron job - and followed this tutorial word to word too
I am still not able to figure out what am I doing wrong?

Well no error in cron job script - it was difference in timezone as pointed out by #parttimeturtle. Also checking logs also helped, thank you both. This was really informative.

Related

Setting up a cronjob on Google Compute Engine

I am new to setting up cronjobs and I'm trying to do it on a virtual machine in google compute engine. After a bit of research, I found this StackOverflow question: Running Python script at Regular intervals using Cron in Virtual Machine (Google Cloud Platform)
As per the answer, I managed to enter the crontab -e edit mode and set up a test cronjob like 10 8 * * * /usr/bin/python /scripts/kite-data-pull/dataPull.py. I also checked the system time, which was in UTC, and entered the time according to that.
The step I'm supposed to take, as per the answer, is to run sudo systemctl restart cron which is throwing an error for me:
sudo systemctl restart cron
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Any suggestions on what I can do to set up this cronjob correctly?
Edit a cron jobs with crontab -e and inset a line:
* * * * * echo test123 > /your_homedir_path/file.log
That will write test123 every minute into file.log file.
Then do tail if and wait a couple minutes. You should see test123 lines appearing in the file (and screen).
If it runs try running your python file but first make your .py file executable with "chmod +x script.py"
Here you can find my reply to similar question.

Cron job backup remote folder to local folder with wget over ftp

Hi everyone would do with some advise
Can not get this simple task working
0 17 * * * wget -m ftp://usarname:password#host.com:port/remote/folder -P /local/folder
what im doing wrong ?
if i run it in terminal line:
wget -m ftp://usarname:password#host.com:port/remote/folder -P /local/folder
it is working as expected but if i add under crontab -e nothing happens.
I would like cron job to check files every day at 17:00 for changes.
thanks in advance
Forgot to restart cron service. Now just need to make it all end to end encrypted.
if you make any changes to services do not forget to restart them :)
restart cron

Using cron Chef cookbook to run a command every 30 mins

I am using the cron cookbook to run every 30 minutes in the following way:
cron_d 'logrotate_check' do
minute "*/30"
command "logrotate -s /var/log/logstatus /etc/logrotate.d/consul_logs"
user 'root'
end
Please let me know if it is correct?
Yes, that is fine. In the future, please just try it yourself rather than asking the internet and waiting 10 hours.

Cron / wget jobs intermittently not running - not getting into access log

I've a number of accounts running cron-started php jobs hourly.
The generic structure of the command is this:
wget -q -O - http://some.site.com/cron.php
Now, this used to be running just fine.
Lately, though, on a number of accounts it has started playing up - but only on this one server. Once or twice a day the php file is not run.
The access log is missing the relevant entry.
While the cron log shows that the job was run.
We've added a bit to the command to log things out (-o /tmp/logfile) but it shows nothing.
I'm at a loss, really. I'm looking for ideas what can be wrong, or how to sidestep this issue as it has started taking up way too much of my time.
Has anyone seen anything remotely like this?
Thanks in advance!
Try this command
wget -d -a /tmp/logfile -O - http://some.site.com/cron.php
With -q you turn off wget's output. With -d you turn on debug output (maybe -v for verbose output is already enough). With -a you append logging messages to /tmp/logfile instead of always creating a new file.
You can also use curl:
curl http://some.site.com/cron.php

cron job fails to restart services

I have a simple script that stops and starts the services (of Oracle Hyperion)
#!bin/ksh
/path/to/dir/stop.sh
sleep 1200
/path/to/dir/start.sh
I have scheduled it for every night and it does run, however there is an issue with database connectivity afterwards. But when i run stop.sh and start.sh manually, there is no such issue. Obviously the job had not run completely.
Here's the output from crontab -l
00 02 * * * /export/home/oracle/scheduled_restart.sh
Could someone please advise on the problem? Thanks.
The usual cause for cron jobs to differ from command line during execution of the exact same code is environment, specifically the variables like ORACLE_SID, TWO_TASK, LD_LIBRARY_PATH, and so on.
Assuming the oracle user own the crontab:
When a job is run by crond it does the equivalent of su oracle, not su - oracle. Try doing something to ensure that the command sources everything the oracle user would normally source during login.
To see what is going on:
/export/home/oracle/scheduled_restart.sh && set > /tmp/my_variables.txt
You do not need the /bin/sh if the /export/home/oracle/scheduled_restart.sh file is executable.
It should have a shebang on line 1. ex: #!/bin/ksh for korn shell or whatever shell you use.

Resources