Page 1 of 2 12 LastLast
Results 1 to 10 of 17

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

  1. #1
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,454
    Distro
    Xubuntu

    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,454
    Distro
    Xubuntu

    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,454
    Distro
    Xubuntu

    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,454
    Distro
    Xubuntu

    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."

  7. #7
    Join Date
    Aug 2009
    Beans
    64

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

    Why are you trying to make an alias run multiple commands?

    An easier way is to make a shell script that performs all the actions you need, and have the alias just run the script.

    Although, if you wanted to, you could probably use "command 1 && command 2" but I'm not entirely sure.

  8. #8
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,454
    Distro
    Xubuntu

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

    I tried this:
    Code:
    :~$ gzip ~/.sportstracker && mv -v ~/.sportsracker.gz ~/Documents/Software/SportsTracker_4.11/SportsTrackerBackup
    The output was:
    Code:
    gzip: /home/rytron/.sportstracker is a directory -- ignored
    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."

  9. #9
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,294
    Distro
    Ubuntu 12.04 Precise Pangolin

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

    You cant gzip a directory. You want something like

    Code:
    tar czvf ~/sportstracker.tar.gz ~/.sportstracker
    「明後日の夕方には帰ってるからね。」


  10. #10
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,454
    Distro
    Xubuntu

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

    Input:
    Code:
    tar czvf ~/sportstracker.tar.gz ~/.sportstracker && mv -v ~/.sportsracker.tar.gz ~/Documents/Software/SportsTracker_4.11/SportsTrackerBackup
    Output:
    Code:
    tar czvf ~/sportstracker.tar.gz ~/.sportstracker && mv -v ~/.sportsracker.tar.gz ~/Documents/Software/SportsTracker_4.11/SportsTrackerBackup
    tar: Removing leading `/' from member names
    /home/rytron/.sportstracker/
    /home/rytron/.sportstracker/sport-types.xml
    /home/rytron/.sportstracker/weights.xml
    /home/rytron/.sportstracker/st-options.xml
    /home/rytron/.sportstracker/notes.xml
    /home/rytron/.sportstracker/exercises.xml
    /home/rytron/.sportstracker/st.dlg.statistic.session.xml
    /home/rytron/.sportstracker/st.dlg.overview.session.xml
    /home/rytron/.sportstracker/st.dlg.options.session.xml
    /home/rytron/.sportstracker/st.dlg.weight.session.xml
    /home/rytron/.sportstracker/st.dlg.sporttype_list.session.xml
    /home/rytron/.sportstracker/st.dlg.sporttype.session.xml
    /home/rytron/.sportstracker/mainFrame.session.xml
    /home/rytron/.sportstracker/st.dlg.exercise.session.xml
    /home/rytron/.sportstracker/st.dlg.statistic_results.session.xml
    mv: cannot stat `/home/rytron/.sportsracker.gz': No such file or directory
    I got the same output for just:
    Code:
    tar czvf ~/sportstracker.tar.gz ~/.sportstracker
    Last edited by Rytron; March 30th, 2010 at 07:31 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."

Page 1 of 2 12 LastLast

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
  •