Skip to main content
edited body
Source Link
Roy Hinkley
  • 305
  • 1
  • 6
  • 16

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:1113 PM.

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:11 PM.

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:13 PM.

deleted 207 characters in body
Source Link
Roy Hinkley
  • 305
  • 1
  • 6
  • 16

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:11 PM.

Based on all of the comments, it appears to be a context issue. How do I get cron to execute under the same user context (in this particular situation) that I use to manually execute the shell script?

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:11 PM.

Based on all of the comments, it appears to be a context issue. How do I get cron to execute under the same user context (in this particular situation) that I use to manually execute the shell script?

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:11 PM.

deleted 7 characters in body
Source Link
Roy Hinkley
  • 305
  • 1
  • 6
  • 16

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron is use:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:11 PM.

Based on all of the comments, it appears to be a context issue. How do I get cron to execute under the same user context (in this particular situation) that I use to manually execute the shell script?

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron is use:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:11 PM.

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.

As far as I know, cron is running with the same user context that I use when logged in to run the script manually. However, given the size differential, that does not appear to be true.

Why are the file sizes different when running the same script?

The shell script contents:

backup_path=/var/custom/db_backups configFile=/var/custom/auth.cnf db_name=[db_name] date=$(date +"%d-%b-%Y") sudo /opt/rh/mysql55/root/usr/bin/mysqldump --defaults-extra-file=$configFile $db_name | gzip -9 > $backup_path/$db_name-$date.sql.gz 

To edit cron:

sudo crontab -e 

cron file contents:

12 21 * * * /var/custom/maint_plan 

This executes the script daily at 9:11 PM.

Based on all of the comments, it appears to be a context issue. How do I get cron to execute under the same user context (in this particular situation) that I use to manually execute the shell script?

added 140 characters in body
Source Link
Roy Hinkley
  • 305
  • 1
  • 6
  • 16
Loading
fixed spelling
Source Link
dr_
  • 32.4k
  • 22
  • 102
  • 148
Loading
added 174 characters in body
Source Link
Roy Hinkley
  • 305
  • 1
  • 6
  • 16
Loading
Source Link
Roy Hinkley
  • 305
  • 1
  • 6
  • 16
Loading