Crontab Random Delay Not Working

I am trying to delay the daily reboot of multiple Linux machines by a random time, within one hour.

This is to avoid a simultaneous reboot of all the Linux machines at the same time.

I also want to avoid specifying a time in cron. I want it to be completely random between 00:00 and 01:00.

So far I tried the commands below, but no luck. The machines still reboot at midnight.

Code:
@daily /bin/sleep $((RANDOM\%3600)) && /sbin/reboot
@daily /bin/sleep $(/usr/bin/expr $RANDOM \% 3600); /bin/reboot



Similar Content



Automatically Starting A Python Script On Startup After Reboot...

I am running a headless Linux 17 media/NAS server. I have setup and tested the plexconnect script and it works. My only issue is that I can't figure out how to get the script to automatically run on startup. I tried using the GUI, but it doesn't seem to work.

To get it to work, I have to open terminal and navigate to the directory:

/usr/local/lib/PlexConnect/

Then run: sudo ./PlexConnect.py

The window has to remain open in order to keep running (which isn't an issue as it's headless). I'd just like to not have to login and start it each time the power goes out, or is rebooted.

I tried editing the crontab file and adding the following variations with no luck:
@reboot python /usr/local/lib/PlexConnect/PlexConnect.py
@reboot /usr/local/lib/PlexConnect/PlexConnect.py

Neither has worked. Does anyone know what I'm doing wrong?

Thanks!

How To Create Large Size File With Some Random Characters And Numbers?

Can anybody tell me how to create large size file in linux? I am using truncate but it is not creating files with some random characters ad numbers.
Please suggest me commands with syntax and example to create large size file with some random characters and numbers in linux with proper explanation.
Thank You.

Cron.daily Symlink (double) Does Not Seem To Be Executing?

Hello,

I cannot understand why the symlink I have put in /etc/cront.daily won't work. It is very possible I am wrong, but my understanding is that cront.{daily,weekly,monthly} works fine with symlinks.

Basically it is double symlink-ed. ls -la on /etc/cron.daily looks like this:

Code:
... 
lrwxrwxrwx  1 root root    49 Nov 27 18:26 rsync_mysql_backups.sh -> /home/myuser/scripts/bash/rsync_mysql_backups.sh
...

Now, ls -la on /home/myuser/scripts looks like this:

Code:
...
lrwxrwxrwx 1 myuser myuser    26 Sep 20  2013 scripts -> /media/md1_storage/scripts
...

I couldn't see anything suspicious in syslog, so I installed postfix in the hope that I will get some sort of information there. Nothing... I also redirected the output of the script to a file in /home/myuser/log.txt but nothing there. The file was not even created.

I am not doing anything mad in the script, I am just synchronising a local directory with a remote one like this:

Code:
/usr/bin/rsync -avzx -e 'ssh -i "/home/myuser/.ssh/myremotehost/id_rsa"' /media/md1_storage/backups/stuff/ myuser@myremotehost:/srv/backups/stuff/ >> /home/myuser/log.txt 2>&1;

As other people suggested in similar threads, I have verified that
Code:
test -x /usr/sbin/anacron

is false, which will result in the execution of the second part of the entry in /etc/crontab:

Code:
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

Any input will be much appreciated. I know I am doing something wrong, but I just cannot see it right now... How can I gather more debugging which will help me understand what's going wrong?

Thanks!

Cronjob Created Empty Files

Hi All,

I have facing a problem with cron job.
Actually on the client server there are some cronjob scheduled
as follows:

@daily sh_file.sh 2>&1>> /dev/null #Contact: vali.zachia@gmail.com
@hourly php demo.php 2>&1 >> /dev/null
10 2 * * * wget --no-check-certificate url 2>&1 > /dev/null #Cron IE
10 2 * * * wget --no-check-certificate url 2>&1 > /dev/null #cron EN
@daily sh script.sh
@daily sh script.sh
@daily sh script.sh
@hourly wget --no-check-certificate url 2>&1 > /dev/null
@daily wget --no-check-certificate url 2>&1 > /dev/null #Cron Poland
@daily wget --no-check-certificate url 2>&1 > /dev/null #Cron Norway
@daily wget --no-check-certificate url 2>&1 > /dev/null #Cron Portugal
10 2 * * * wget --no-check-certificate url 2>&1 > /dev/null #Cron GR
@daily wget --no-check-certificate url 2>&1 > /dev/null
@daily wget --no-check-certificate url 2>&1 > /dev/null
@daily wget --no-check-certificate url 2>&1 > /dev/null #Denmark



Cronjobs are scheduled daily/hourly.

But what happends after every hour/day there is a blank file created in a folder .

like :
hourly.1

hourly.2
hourly.3
hourly.4

and so on similary for daily scripts.

I am not sure whether these are created by cron job
So please clarify whether cronjob provides some thing like above or it is the code problem

Unwanted Recovery Mode Option When Rebooting

In Mint Cinnamon 17.1, every time I reboot, I get an option in GRUB to boot into recovery mode. I have to then manually select normal (not recovery mode) booting, after which I get to the regular Cinnamon desktop. This started happening after the computer froze one time and I had to power it off, but it happens every time I reboot now. Bottom line: on reboot, I need to go through an extra, unnecessary step of selecting normal, rather than recovery, mode. Does anyone know how to get rid of this recovery mode option in GRUB?

Why Did My Firewall Start

hi experts

i got a centos instance that I recently rebooted, after reboot I found the iptable is running. previously i had turned it off but for some reason it started again.

this is the run level for ip table:
Code:
0:off 1:off 2:on 3:on 4:on 5:on 6:off

I am trying to figure out if with this combo, iptable auto starts? because 6 is for system reboot and if it was off then that means it shouldn't be started right?

thanks

Install Problems

Hello,
Tried to check other questions first, but didnt find any that were the same so here goes.....
Have an older pc with MSI motherboard: ms-7039 V 1.3. Other id's are N1996 and K9N6PGM2-V man. date 6/11/2008. Has bios v 9.1 simbios v 2.5 This is a 32bit.
Have formatted satas (plural because tried different drives to be sure not bad) in ntfs, partitioned according to instructions.
Have created 2 bootable usb's both 32bit, of ubuntu and mint. These both are fine as checked them on other machines so thats not the problem.
Can load win7 just fine, when go through install of these distros all goes well until says to reboot. Once reboot, loads up and either get 1. a fuzzy screen just with color 2. the screen with only icons on top right (ubuntu) sometimes mouse works sometimes not or 3. all icons top right and on left, but either mouse not work, moves in jerks and in both of these cases cannot click on icons.
Any ideas? Any thoughts would be appreciated. Thanks.

I Tried To Full Install Puppy Linux 4.3.1 From Cd But Will Not Reboot Without Cd

Im trying to break free from windows. just got puppy 4.3.1 and know nothing about linux . after trying a full install it will not reboot without cd in the drive, just says error loading operating system.My system has more than required amount of ram and almost 40 gig hd. have only 1 partition formated to ext2. could not figure how to use grub.

ps. also canot connect to wireless router

Linux Resets Every Time Is Reboots Or Shuts Down

I'm running Linux on a VMware player and every time I reboot it or shut it down it does not keep any of the changes I have made. Please help.

Parallel File System Check

Reboot of Linux server consuming more time when there is a file system check (fsck)
Most of our server are using ext3 file system
Is there any possibility to make parallel fsck during reboot ?