Set up cron job every minute CPANEL - cron

I tried to set up the cron job any minute, I tried 3 different commands.
Any of them is not working.
Below is the error:

Run cron job every minute
The syntax is:
* * * * * /path/to/your/script > output

Related

Wait 60 Seconds to Run Cron Job After Reboot Then Run Job Every 10 Minutes

I have a script that I would like to run 60 seconds after initial system reboot and then every 10 minutes after that. I currently need two cron job listings to achieve this:
*/10 * * * * php myscript.php
#reboot /bin/sleep 60; php myscript.php
The first listing will run my cron job immediately after system boot and so I need to have the second listing to account for the on start wait time.
Is there anyway to combine the above two cron listings into one?

How to start cron jobs removing offset?

I am running a cron job which will run at every 5 minutes.
Now Let's say i have started job on 04:02 so it will execute at every 5 minutes so will execute on 04:07, 04:12, 04:17 etc...
Let's say i have started job on 13:18 so it will executed at 13:23, 13:28, 13:33 etc...
But what i want is it should only execute in multiplication of 5 minutes means if i create job on 04:02, it should start executing from 04:05, 04:10 and so on.
And if start job on 13:18, it should start executing from 13:20, 13:25 and so on.
So how to achieve this?
Try this:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * <Your command>
*/5 * * * *
this should be what you want .

How the cron timing is working?

Suppose, current time is 11:42 and i have setup one cron file to run at every 5 minutes.
Then this file will run at which time 11:47 or 11:45?
So basically i am trying to understand that how the cron timing is work?
Edit : it was ran at 11:45, but i don't know the reason behind it
Cron Configuration :
*/5 * * * * wget -O /dev/null http://XXX/index.php?r=controller/action
As you know, cron will run jobs at a specific time.
A cron job will not use the time it was started, only the configuration matters. This means a cron job set to every 5 minutes (like your */5 * * * *) will only ever run at times ending with 0 or 5 (eg: 12:00, 12:05, 12:10), regardless of the time you run it. This makes sense because we want to schedule a job for a specific time.
If you really need a job to run every 5 minutes, with an offset (eg: 11:42, 11:47, 11:52) you will have to give a list in the configuration.
instead of (*/5 * * * *) you would need to use:
(2,7,12,...,57 * * * *), filling ... with all the other numbers.

Is this the correct way to run a script at certain hours?

I'd like a cron job to run a command at:
8am
10am
5pm
7pm
9pm
11pm
I've tried this, but when I check my logs, I see that the command is run too many times.
* 8,10,17,19,21,23 * * * COMMAND >> mylog.txt
Your command means "run on every minute of the given hours". If you want to run it just once, you need to set the minute field, e.g.:
0 8,10,17,19,21,23 * * * COMMAND >> mylog.txt
This way the command only runs at the start (minute 0) of each of the given hours

Unsure what is wrong with cron tab

I am attempting to schedule a cron job for database backups using percona extra backup.
My cron job is in cron.d and looks as follows;
exec &>/var/tmp/cron.log
1 * * * * * secondstory_prod /var/opt/backup/percona_xtrabackup_incremental.sh > /var/tmp/cron.log
The error i receive when i try and force the jobs to run in the log file listed above is /etc/cron.d/db_backup_daily: line 2: 1: command not found
If i try to run the jobs forcefully with run-parts /etc/cron.d i get the above error.
What is strange is that if i navigate to the directory and run the percona_xtrabackup_incremental.sh file it works with no issues.
Please can someone help?
Thanks
Your problem is you have one too many * in your cron entry.
1 * * * * * secondstory_prod ..stuff..
should be
1 * * * * secondstory_prod ..stuff..
will run on every 1st minute of each hour every day (above). The general time entry format is:
* minute (0-59)
* hour (0-23)
* day of month (1-31)
* month (1-12)
* day of week (0-6) (0=Sunday)

Resources