Schedule Shell Script

Discussion in 'Programming/Scripts' started by GMSS, Nov 20, 2017.

  1. GMSS

    GMSS New Member

    Hi Guys,
    I need a shell script that will output the command "ps aux" to a file name "Tuesday" every second for 10 seconds to the path /home/user/Desktop.
    Seeing that it will run every second to the same directory, the filename will need to increment as well i.e Tuesday2, Tuesday3, Tuesday4.....Tuesday10. Can someone please help with this?

    Many Thanks in advance

    Kind Regards
    GMS
     
  2. GMSS

    GMSS New Member

    Hi Guys,
    Since no one has answered, I've crudely decide to run this manually but rather than creating new file names, I decided to append the output to the same file separated by new lines. Here is the command I ran:

    ps aux >> /home/user/Desktop/Tuesday | echo $'\n\n\n\n\n' >> /home/user/Desktop/Tuesday

    The double '>>' means to append to output of 'ps aux' to the same file
    echo $'\n\n\n\n\n' - creates 5 new lines in the file Tuesday so as to identify separation.

    Hope this will help someone too.

    Kind Regards
    GMSS
     
    ahrasis and till like this.

Share This Page