Results 1 to 10 of 17

Thread: How do I automate or make an alias of this task?

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Question How do I automate or make an alias of this task?

    Hi.
    Could I make an alias of this task?

    I want an alias to move ~/.sportstracker to ~/Documents/Software/SportsTracker_4.1.1 and then zip it and name the zip file like this SportsTrackerBackup_yyyy-mm-dd (example: SportsTrackerBackup_2010-03-08)

    Note: I don't mind how the archive is compressed, 7z, rar, zip, tar, etc. Although the higher the compression the better.

    Else, is there a way to automate this daily or once a week?
    Last edited by Rytron; March 8th, 2010 at 01:20 PM.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  2. #2
    Join Date
    Jun 2009
    Location
    0000:0400
    Beans
    Hidden!

    Re: How do I automate or make an alias of this task?

    i'd write it as a bash function. It works the same and goes in the same place, but follows slightly different rules:

    Code:
    stracker() {
      gzip ~/.sportstracker
      mv -v ~/.sportsracker.gz ~/Documents/Software/SportsTracker_4.11/SportsTrackerBackup_$(date +%F)
    }
    If you wanted this automated, you could take the two real commands out of this and throw them into a script file for use as a cron job. There would be some further changes necessary though.

  3. #3
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Post Re: How do I automate or make an alias of this task?

    Thank you falconindy. It does not work though.

    Just a quick correction on your code:

    Code:
    stracker() {
      gzip ~/.sportstracker
      mv -v ~/.sportstracker.gz ~/Documents/Software/SportsTracker_4.11/SportsTrackerBackup_$(date +%F)
    }
    I made this file like so from your code [attached].
    Attached Files Attached Files
    Last edited by Rytron; March 8th, 2010 at 04:11 PM.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  4. #4
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Lightbulb Re: How do I automate or make an alias of this task?

    Does anyone know how to solve this?

    Is it possible to combine two commands in one alias? For example, something to do this:

    1. gzip ~/.sportstracker
    2. mv -v ~/.sportsracker.gz ~/Documents/Software/SportsTracker_4.11/SportsTrackerBackup


    I am not certain the above syntax is 100% correct though.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  5. #5
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: How do I automate or make an alias of this task?

    you have to add the function to the ~/.bashrc file & (re)source the file:
    Code:
    . ~/.bashrc
    or start a new bash session.

    if you plan to write more function, you may want to keep them in a separate file (i.e. ~/.bash_functions) & add something like:
    Code:
    [ -f ~/.bash_functions ] && . ~/.bash_functions
    to the ~/.bashrc file.

    See:
    Code:
    man bash | less +/"\. *filename *\[arguments\]"

  6. #6
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Question Re: How do I automate or make an alias of this task?

    I'm lost.

    I just want an easy way to archive ~/.sportstracker & move it to the SportsTrackerBackup at ~/Documents/Software/SportsTracker_4.11/SportsTrackerBackup
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •