How can I run a script through crontab with a value input for the script?How to execute shell script via...

How would an AI self awareness kill switch work?

How much mayhem could I cause as a sentient fish?

Explain the objections to these measures against human trafficking

How to deal with an incendiary email that was recalled

Writing a character who is going through a civilizing process without overdoing it?

Would the Vulcan nerve pinch work on a Borg drone?

Why does the Spectator have the Create Food and Water trait, instead of simply not requiring food and water?

How can I get my players to come to the game session after agreeing to a date?

How do you funnel food off a cutting board?

Avoiding morning and evening handshakes

Do authors have to be politically correct in article-writing?

How long is the D&D Starter Set campaign?

How to prevent cleaner from hanging my lock screen in Ubuntu 16.04

Why exactly do action photographers need high fps burst cameras?

Can a person refuse a presidential pardon?

Why is mind meld hard for T'pol in Star Trek: Enterprise?

Blindfold battle as a gladiatorial spectacle - what are the tactics and communication methods?

What is 6÷2×(1+2) =?

Why publish a research paper when a blog post or a lecture slide can have more citation count than a journal paper?

Incorporating research and background: How much is too much?

How can my powered armor quickly replace its ceramic plates?

What is the wife of a henpecked husband called?

Why did the villain in the first Men in Black movie care about Earth's Cockroaches?

Publishing research using outdated methods



How can I run a script through crontab with a value input for the script?


How to execute shell script via crontab?How to use crontab to run a script as nobodyCrontab doesn't run my script UbuntuRun crontab non-interactively from scriptHow can a bash script run several others scripts?Why doesn't my script run via crontab?How to configure a cron.d crontab file for rootCrontab not executing my python script, any input? [Solved]Getting the crontab text template from within a bash scriptHow can I execute all commands in crontab subsequently?













0















im trying to run a script with crontab on linux as follow,
i create a script for a incremental backup.



when i excecute in the command line/usr/bin/diego-backup.sh complete the script creates a complete backup of the system if not creates it incremental the problem comes when i configure it to run through the crontab 0 0 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) in this case the backup script creates a file that it is not a complete backup.



Could anyone tell me what i'm doing wrong?



Script 1: Turns off all the Virtual Maschines



virsh shutdown Odoo
virsh shutdown OpenZ
virsh shutdown mssqlserver
virsh shutdown Zentyal_HOME


Script 2: Creates Backups



#cat > /usr/local/sbin/backup.sh << EOF
#!/bin/sh
BACKUPDIR=/media/backup
LASTMONTHDIR=lastmonth
TSNAME=timestamp.snar
BACKUPNAME=backup
DIRS="/"
if [ $1 == "complete" ]; then
#Komplettes Backup
MYDATE=complete
#Alte Timestamps löschen
rm -f "$BACKUPDIR/$TSNAME"
#Alte Backups löschen
rm -rf "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
#Neue alte Backups in Ordner verschieben
mkdir "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
mv -f "$BACKUPDIR/$BACKUPNAME.*".tgz
"$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
else
#Inkrementelles Backup
MYDATE=$(date +%y%m%d)
fi
#Abzug erstellen
tar czf "$BACKUPDIR"/"$BACKUPNAME".$MYDATE.tgz --exclude=/proc --exclude=/lost+found --exclude=/media --exclude=/mnt$
#EOF chmod +x /usr/local/sbin/backup.sh


Script 3: Starts the Virtual Machines



#!/bin/sh
sudo echo "Starte die Virtual Maschinen an..."
xmlfiles=( $(find /etc/libvirt/qemu/autostart/ -name '*.xml') )
for f in "${xmlfiles[@]}" ; do
domain=$(xml2 < $f | awk -F= '$1 == "/domain/name" {print $2}')
# only start domain if it's not already running
if ! virsh list | grep " ${domain} .*running" ; then
virsh start "$domain"
#else
# optionally reboot domain otherwise
#virsh reboot "$domain"
fi
done


Crontab like this:



41 12 * * * /usr/bin/diego-virt-stoppen.sh >> /home/sysadm/`date +%Y%m%d%H%M%S`-virt-stop.log 2>&1
48 15 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) >> /home/sysadm/`date +%Y%m%d%$`


Thanks!










share|improve this question









New contributor




Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Not without some more information.

    – harrymc
    11 hours ago











  • what kind of information?

    – Diego Valiente
    11 hours ago











  • Post your scripts, for example.

    – harrymc
    11 hours ago











  • Ready, took a while.

    – Diego Valiente
    11 hours ago











  • Question 1: Where is the virsh executable? cron jobs run with a very minimal path, so the start and stop scripts might not be finding it. Second, what do you get if you capture the error output from the backup script? (For that matter, what's the output you get in the existing logging?)

    – Gordon Davisson
    14 mins ago


















0















im trying to run a script with crontab on linux as follow,
i create a script for a incremental backup.



when i excecute in the command line/usr/bin/diego-backup.sh complete the script creates a complete backup of the system if not creates it incremental the problem comes when i configure it to run through the crontab 0 0 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) in this case the backup script creates a file that it is not a complete backup.



Could anyone tell me what i'm doing wrong?



Script 1: Turns off all the Virtual Maschines



virsh shutdown Odoo
virsh shutdown OpenZ
virsh shutdown mssqlserver
virsh shutdown Zentyal_HOME


Script 2: Creates Backups



#cat > /usr/local/sbin/backup.sh << EOF
#!/bin/sh
BACKUPDIR=/media/backup
LASTMONTHDIR=lastmonth
TSNAME=timestamp.snar
BACKUPNAME=backup
DIRS="/"
if [ $1 == "complete" ]; then
#Komplettes Backup
MYDATE=complete
#Alte Timestamps löschen
rm -f "$BACKUPDIR/$TSNAME"
#Alte Backups löschen
rm -rf "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
#Neue alte Backups in Ordner verschieben
mkdir "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
mv -f "$BACKUPDIR/$BACKUPNAME.*".tgz
"$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
else
#Inkrementelles Backup
MYDATE=$(date +%y%m%d)
fi
#Abzug erstellen
tar czf "$BACKUPDIR"/"$BACKUPNAME".$MYDATE.tgz --exclude=/proc --exclude=/lost+found --exclude=/media --exclude=/mnt$
#EOF chmod +x /usr/local/sbin/backup.sh


Script 3: Starts the Virtual Machines



#!/bin/sh
sudo echo "Starte die Virtual Maschinen an..."
xmlfiles=( $(find /etc/libvirt/qemu/autostart/ -name '*.xml') )
for f in "${xmlfiles[@]}" ; do
domain=$(xml2 < $f | awk -F= '$1 == "/domain/name" {print $2}')
# only start domain if it's not already running
if ! virsh list | grep " ${domain} .*running" ; then
virsh start "$domain"
#else
# optionally reboot domain otherwise
#virsh reboot "$domain"
fi
done


Crontab like this:



41 12 * * * /usr/bin/diego-virt-stoppen.sh >> /home/sysadm/`date +%Y%m%d%H%M%S`-virt-stop.log 2>&1
48 15 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) >> /home/sysadm/`date +%Y%m%d%$`


Thanks!










share|improve this question









New contributor




Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Not without some more information.

    – harrymc
    11 hours ago











  • what kind of information?

    – Diego Valiente
    11 hours ago











  • Post your scripts, for example.

    – harrymc
    11 hours ago











  • Ready, took a while.

    – Diego Valiente
    11 hours ago











  • Question 1: Where is the virsh executable? cron jobs run with a very minimal path, so the start and stop scripts might not be finding it. Second, what do you get if you capture the error output from the backup script? (For that matter, what's the output you get in the existing logging?)

    – Gordon Davisson
    14 mins ago
















0












0








0








im trying to run a script with crontab on linux as follow,
i create a script for a incremental backup.



when i excecute in the command line/usr/bin/diego-backup.sh complete the script creates a complete backup of the system if not creates it incremental the problem comes when i configure it to run through the crontab 0 0 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) in this case the backup script creates a file that it is not a complete backup.



Could anyone tell me what i'm doing wrong?



Script 1: Turns off all the Virtual Maschines



virsh shutdown Odoo
virsh shutdown OpenZ
virsh shutdown mssqlserver
virsh shutdown Zentyal_HOME


Script 2: Creates Backups



#cat > /usr/local/sbin/backup.sh << EOF
#!/bin/sh
BACKUPDIR=/media/backup
LASTMONTHDIR=lastmonth
TSNAME=timestamp.snar
BACKUPNAME=backup
DIRS="/"
if [ $1 == "complete" ]; then
#Komplettes Backup
MYDATE=complete
#Alte Timestamps löschen
rm -f "$BACKUPDIR/$TSNAME"
#Alte Backups löschen
rm -rf "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
#Neue alte Backups in Ordner verschieben
mkdir "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
mv -f "$BACKUPDIR/$BACKUPNAME.*".tgz
"$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
else
#Inkrementelles Backup
MYDATE=$(date +%y%m%d)
fi
#Abzug erstellen
tar czf "$BACKUPDIR"/"$BACKUPNAME".$MYDATE.tgz --exclude=/proc --exclude=/lost+found --exclude=/media --exclude=/mnt$
#EOF chmod +x /usr/local/sbin/backup.sh


Script 3: Starts the Virtual Machines



#!/bin/sh
sudo echo "Starte die Virtual Maschinen an..."
xmlfiles=( $(find /etc/libvirt/qemu/autostart/ -name '*.xml') )
for f in "${xmlfiles[@]}" ; do
domain=$(xml2 < $f | awk -F= '$1 == "/domain/name" {print $2}')
# only start domain if it's not already running
if ! virsh list | grep " ${domain} .*running" ; then
virsh start "$domain"
#else
# optionally reboot domain otherwise
#virsh reboot "$domain"
fi
done


Crontab like this:



41 12 * * * /usr/bin/diego-virt-stoppen.sh >> /home/sysadm/`date +%Y%m%d%H%M%S`-virt-stop.log 2>&1
48 15 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) >> /home/sysadm/`date +%Y%m%d%$`


Thanks!










share|improve this question









New contributor




Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












im trying to run a script with crontab on linux as follow,
i create a script for a incremental backup.



when i excecute in the command line/usr/bin/diego-backup.sh complete the script creates a complete backup of the system if not creates it incremental the problem comes when i configure it to run through the crontab 0 0 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) in this case the backup script creates a file that it is not a complete backup.



Could anyone tell me what i'm doing wrong?



Script 1: Turns off all the Virtual Maschines



virsh shutdown Odoo
virsh shutdown OpenZ
virsh shutdown mssqlserver
virsh shutdown Zentyal_HOME


Script 2: Creates Backups



#cat > /usr/local/sbin/backup.sh << EOF
#!/bin/sh
BACKUPDIR=/media/backup
LASTMONTHDIR=lastmonth
TSNAME=timestamp.snar
BACKUPNAME=backup
DIRS="/"
if [ $1 == "complete" ]; then
#Komplettes Backup
MYDATE=complete
#Alte Timestamps löschen
rm -f "$BACKUPDIR/$TSNAME"
#Alte Backups löschen
rm -rf "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
#Neue alte Backups in Ordner verschieben
mkdir "$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
mv -f "$BACKUPDIR/$BACKUPNAME.*".tgz
"$BACKUPDIR/$LASTMONTHDIR.$BACKUPNAME.d"
else
#Inkrementelles Backup
MYDATE=$(date +%y%m%d)
fi
#Abzug erstellen
tar czf "$BACKUPDIR"/"$BACKUPNAME".$MYDATE.tgz --exclude=/proc --exclude=/lost+found --exclude=/media --exclude=/mnt$
#EOF chmod +x /usr/local/sbin/backup.sh


Script 3: Starts the Virtual Machines



#!/bin/sh
sudo echo "Starte die Virtual Maschinen an..."
xmlfiles=( $(find /etc/libvirt/qemu/autostart/ -name '*.xml') )
for f in "${xmlfiles[@]}" ; do
domain=$(xml2 < $f | awk -F= '$1 == "/domain/name" {print $2}')
# only start domain if it's not already running
if ! virsh list | grep " ${domain} .*running" ; then
virsh start "$domain"
#else
# optionally reboot domain otherwise
#virsh reboot "$domain"
fi
done


Crontab like this:



41 12 * * * /usr/bin/diego-virt-stoppen.sh >> /home/sysadm/`date +%Y%m%d%H%M%S`-virt-stop.log 2>&1
48 15 * * * (/usr/bin/diego-backup.sh complete && /usr/bin/diego-virt-starten.sh) >> /home/sysadm/`date +%Y%m%d%$`


Thanks!







linux bash script bash-scripting crontab






share|improve this question









New contributor




Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 6 mins ago









JakeGould

31.6k1096138




31.6k1096138






New contributor




Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 12 hours ago









Diego ValienteDiego Valiente

11




11




New contributor




Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Diego Valiente is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Not without some more information.

    – harrymc
    11 hours ago











  • what kind of information?

    – Diego Valiente
    11 hours ago











  • Post your scripts, for example.

    – harrymc
    11 hours ago











  • Ready, took a while.

    – Diego Valiente
    11 hours ago











  • Question 1: Where is the virsh executable? cron jobs run with a very minimal path, so the start and stop scripts might not be finding it. Second, what do you get if you capture the error output from the backup script? (For that matter, what's the output you get in the existing logging?)

    – Gordon Davisson
    14 mins ago





















  • Not without some more information.

    – harrymc
    11 hours ago











  • what kind of information?

    – Diego Valiente
    11 hours ago











  • Post your scripts, for example.

    – harrymc
    11 hours ago











  • Ready, took a while.

    – Diego Valiente
    11 hours ago











  • Question 1: Where is the virsh executable? cron jobs run with a very minimal path, so the start and stop scripts might not be finding it. Second, what do you get if you capture the error output from the backup script? (For that matter, what's the output you get in the existing logging?)

    – Gordon Davisson
    14 mins ago



















Not without some more information.

– harrymc
11 hours ago





Not without some more information.

– harrymc
11 hours ago













what kind of information?

– Diego Valiente
11 hours ago





what kind of information?

– Diego Valiente
11 hours ago













Post your scripts, for example.

– harrymc
11 hours ago





Post your scripts, for example.

– harrymc
11 hours ago













Ready, took a while.

– Diego Valiente
11 hours ago





Ready, took a while.

– Diego Valiente
11 hours ago













Question 1: Where is the virsh executable? cron jobs run with a very minimal path, so the start and stop scripts might not be finding it. Second, what do you get if you capture the error output from the backup script? (For that matter, what's the output you get in the existing logging?)

– Gordon Davisson
14 mins ago







Question 1: Where is the virsh executable? cron jobs run with a very minimal path, so the start and stop scripts might not be finding it. Second, what do you get if you capture the error output from the backup script? (For that matter, what's the output you get in the existing logging?)

– Gordon Davisson
14 mins ago












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Diego Valiente is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1410223%2fhow-can-i-run-a-script-through-crontab-with-a-value-input-for-the-script%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Diego Valiente is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Diego Valiente is a new contributor. Be nice, and check out our Code of Conduct.













Diego Valiente is a new contributor. Be nice, and check out our Code of Conduct.












Diego Valiente is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1410223%2fhow-can-i-run-a-script-through-crontab-with-a-value-input-for-the-script%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...