RHEL 5.3: crontab runs multiple instances of script - cron

I have a simple script that runs perfectly when used manually. When I entered into my crontab to run at 10 PM each night it appears to run several instances of the script, and times out my server. Any ideas?
22 * * * /mnt/myscript.sh

you are doing it wrong. It should've been
00 22 * * /mnt/myscript.sh.
Read about crons here.
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/ch-autotasks.html

Related

Schedule auto shutdown and restart on specific days - Express Server

I would like to configure my Express Server to stop automatically at 3:00 pm on Saturdays and restart at 4:00am on Mondays. How could I do this ?
Also, I would like it to restart automatically if it crashes without waiting for file changes (I'm using nodemon).
You can write scripts that starts and kills the server and add them in a cronjob service, for example cron in linux.
For example: say script start.sh and stop.sh are in home directory that start and stop your server.
Add these lines to crontab file:
00 15 * * 6 ~/start.sh
00 04 * * 1 ~/stop.sh
First line: 3 PM on all Saturdays
Second line: 4 AM on all Mondays
Reference: Link

Created cron job to run every 2 mint

I have configured cron job but it's not working.
I wanted to run the myfile.sh script for every 2 mint and below are my configuration in crontab.
# m h dom mon dow comman
2 * * * * /home/ubuntu/myfile.sh
myfile.sh is executable and contains below lines of code
#!/bin/bash
mysqldump -u[user] -p[password] --single-transaction --routines --triggers --all-databases > /home/ubuntu/backup_db10.sql
Is there anywhere we need to add configure anything?
You're running the script at two minutes past every hour. As in 1:02, 2:02 and so on.
You can change it to something like
*/2 * * * * /home/ubuntu/myfile.sh
to run it every two minutes.
A bit more info can be found here.

Cron job not running automatically for a non-root user

I am running SUSE Linux as a non-root user (getting root access also will not be a possibility). I would like to have a .sh script I created be run daily.
My crontab looks like:
0 0 * * * * /path/to/file.sh
I also have a line return after this as per many troubleshooting suggestions. My script deletes files older than 14 days. I also added a means to log output to check whether the script runs.
However, the job does not run automatically. I also am not able to check /var/log/messages for any notifications on whether cron can run or not.
What am I doing wrong? How can I check if cron itself is running/can run for my user? Do I have to supply cron with any paths or environment variables?
The correct approach to run your cron every midnight is:
00 00 * * * /bin/bash path/to/your/script.sh >> /path/to/log/file.log

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.

Cron schedule - Execute job at three different times with no pattern between. Is it possible?

I have a job I want to run using Quartz, which require the time to be specified using a Cron schedule.
The job should run at 17:00, 17:35 and 22:05.
Is it possible to specify these times using a Cron schedule ? I've already looked into the Wikipedia article, but it did not help much. From my point of view, there needs to be a pattern between the times, so that you can specify them using a Cron schedule.
Best regards
Nicolas
You can do it with 3 cron jobs. example :
> crontab -e
00 17 * * * sh /example/script.sh
35 17 * * * sh /example/script.sh
05 22 * * * sh /example/script.sh

Resources