ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Cron task based on command line tasks.

    IT Discussion
    2
    3
    106
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JasGot
      last edited by

      I always fight with this, and today is no different. I have a command that I run at the command line and it works perfectly. However, I cannot get it to run as a cron job, and don't have any idea where to look for problems (logs) to even begin to troubleshoot. I know I can turn my one liner into a shell script, and cron that, but it has become a challenge for me to figure out how to write complex cron tasks.

      Here is what I run at the command line:

      /usr/bin/mysqldump -u root -prootpassword nextcloud > /tmp/nextcloud.sql; sudo 7z a -pencryptionpassword  /tmp/nextcloud.7z /tmp/nextcloud.sql /var/www/nextcloud/config/config.php; echo "Today's backup of the My Nextcloud SQL Data is attached." | /usr/bin/mailx -A /tmp/nextcloud.7z -s "Cloud.example.Com Nextcloud SQL Backup" -r "[email protected]" [email protected]
      

      Any helpful ideas from those smarter than me?

      scottalanmillerS 1 Reply Last reply Reply Quote 0
      • scottalanmillerS
        scottalanmiller @JasGot
        last edited by

        @JasGot said in Cron task based on command line tasks.:

        I know I can turn my one liner into a shell script, and cron that, but it has become a challenge for me to figure out how to write complex cron tasks.

        You make it a script. Cron tasks have to always be simple. Single command, don't let any complexity creep into the cron area.

        1 Reply Last reply Reply Quote 1
        • scottalanmillerS
          scottalanmiller
          last edited by

          @JasGot said in Cron task based on command line tasks.:

          #!/bin/bash
          /usr/bin/mysqldump -u root -prootpassword nextcloud > /tmp/nextcloud.sql 
          7z a -pencryptionpassword  /tmp/nextcloud.7z /tmp/nextcloud.sql /var/www/nextcloud/config/config.php
          echo "Today's backup of the My Nextcloud SQL Data is attached." | /usr/bin/mailx -A /tmp/nextcloud.7z -s "Cloud.example.Com Nextcloud SQL Backup" -r "[email protected]" [email protected]
          

          Make that a file, run with cron.

          1 Reply Last reply Reply Quote 3
          • 1 / 1
          • First post
            Last post