Hello,
I am trying to include as much information as possible because I am not able to figure out why the cron.job is not running.
I made two files for running on cron.hourly. When I run thethey both run fine. I want to move this to cron.monthly and have only put the files in cron.hourly for testing. I am including file permissions information belowrun-parts -v /etc/cron.hourly
-rwxr-xr-x 1 root root 1330 Jun 5 03:20 data_backup
-rwxr-xr-x 1 root root 948 Jun 5 03:43 systembk
The script from both files is below. Now there is a customized command for 'gcloud' which is google's cloud however, I think the problem is related to script and nothing to to do with that specific command.
data_backupfile
The second file is for taking backup of the system disk and I believe I am doing something wrong (maybe owner has to be the user not the root or is there something related to crontab.#!/bin/bash
# Date: June 3 2015
#
# Goal is to backup the data disk (take snapshot)
# Following the guidelines in documentation mentioned below
################################################## ########
#
# Comments
# Comments
#
#Comments
#
################################################## ########
PATH=/sbin:/bin:/usr/bin:/usr/bin/gcloud
echo $PATH
#sudo pkill -u user1
#sudo pkill -u user2
###sudo sync
###sudo fsfreeze -f /home/user1/Desktop/data
# Alternative to the above two commands of sync and fsfreeze
# Umount all the attachd drives (except the boot disk)
sudo umount -a
echo umount
data1=databackup-1-$(date +"%Y-%m-%d-%H-%M")
data2=databackup-2-$(date +"%Y-%m-%d-%H-%M")
echo $data1
#gcloud compute disks snapshot disk-3 disk-4 \
#--zone us-central1-b
##--snapshot-names databackup-1 databackup-2 --zone us-central1-b
gcloud compute disks snapshot disk-3 disk-4 \
--snapshot-names $data1 $data2 --zone us-central1-b
###sudo fsfreeze -u /home/user1/Desktop/data
#Alternative to Fsfreeze
sudo mount -a
I think I am missing a some basic step here.
My thoughts#!/bin/bash
# Date: June 3 2015
#
# Goal is to backup the system disk (take snapshot)
# Following the guidelines in documentation mentioned below
################################################## ########
#
# Comment 1
# Comment 2
#
#
################################################## ########
# This is system disk so will have to take a live snapshot
PATH=/sbin:/bin:/usr/bin:/usr/bin/gcloud
# Flush data from buffers
sudo sync
sysdata1=sysdatabackup-1-$(date +"%Y-%m-%d-%H-%M")
gcloud compute disks snapshot analyze-2 \
--snapshot-names $sysdata1 --zone us-central1-b
1) Make an executable script and move it to /etc/cron.hourly/ folder
2) Now test is with $run-parts -v /etc/cron.hourly/
3) If tests runs ok. your script should work ? (That is my assumption)
Thanks in advance for your help
Bookmarks