Create file when script has executed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create file when script has executed
# 1  
Old 08-25-2018
Create file when script has executed

I would like to get some kind of notification when a script has been executed.


I know how to get an email sent, but I something different.


This works, unless it occurs when I am not at my computer.
Code:
notify-send "Cleanup of Backup Directories complete."

It could even involve creating a file in a directory.

I would need to create said file from within my backup script.

Update:

This works,
Code:
zip -u -q test.zip *.txt *.doc *.rtf *.html *.png *.pdf *.odt *.ods *.odg 
cp "Ubuntu_Documents.zip" /home/andy/Downloads > filebackup.txt

but I get
Code:
cp: cannot stat 'Ubuntu_Documents.zip': No such file or directory


Last edited by drew77; 08-25-2018 at 09:19 PM..
# 2  
Old 08-26-2018
Quote:
Originally Posted by drew77
I would like to get some kind of notification when a script has been executed.

Note that this could be a problematic proposition because once the script has been run the file is there. How do you set apart the file that has already been there from the first run from the file to be created by the second run, hmm?

Quote:
Originally Posted by drew77
Code:
zip -u -q test.zip *.txt *.doc *.rtf *.html *.png *.pdf *.odt *.ods *.odg 
cp "Ubuntu_Documents.zip" /home/andy/Downloads > filebackup.txt

but I get
Code:
cp: cannot stat 'Ubuntu_Documents.zip': No such file or directory

This is most probably because zip doesn't write to a file named Ubuntu_Documents.zip". Perhaps your zip-file has some other name (i suppose, from the commandline, "test.zip") and you would have to reflect this name in the cp-command.

Furthermore, are you sure you want to name the file "whatever.txt"?? A file ending in .txt is supposed to be plainly readable text and .zip-files aren't exactly that.

I hope this helps.

bakunin
# 3  
Old 08-26-2018
You are right.

I went with
Code:
touch /media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/$( date '+%Y-%m-%d_%H:%M' )

I have another script that deletes the older files.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script is not getting executed

Hi All, I have written a programme where i need to work in one session but when that session get executed it doesnt execute other programme till I write exit. Below is the script #!/bin/bash echo 'Going to start' exectrusteduser.com sh.com cd /UAT_Logs/CDCI_LOGS/SEEDADM pwd echo... (6 Replies)
Discussion started by: ripudaman.singh
6 Replies

2. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

3. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

Hi, I am having a shell script which has a while loop as shown below. while do sleep 60 done I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies

4. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

5. AIX

Script not getting executed via cron but executes when executed manually.

Hi Script not getting executed via cron but executes successfully when executed manually. Please assist cbspsap01(appuser) /app/scripts > cat restart.sh #!/bin/ksh cd /app/bin date >>logfile.out echo "Restart has been started....." >>logfile.out date >>logfile.out initfnsw -y restart... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

6. Shell Programming and Scripting

Create a file from within a script

Hi, I want to create a file from within a script that checks whether the file itself exists or not. Like: if ] then echo Creating file... cat << EOF > .theFile echo This line should be in the file EOF fi If I run the script with no condition (commenting... (2 Replies)
Discussion started by: lamano
2 Replies

7. Shell Programming and Scripting

create file in script

hi i am reading a directory, and reading those files one by one i need to write some of file contents to a new file ,for this i need to create a new file for each file please tell me how to create new file in shell script thanks Satya (4 Replies)
Discussion started by: Satyak
4 Replies

8. Shell Programming and Scripting

How to know who executed a script?

Dear all I would like to capture who executed a script to a script's variable (i.e. testing.sh), so I can save it to a log file. testing.sh #! bin/ksh user=`<< code here >>` // get the info below in RED color <<main logic>> echo "$user execute testing.sh on `date`" >> testing.log ... (2 Replies)
Discussion started by: on9west
2 Replies

9. Shell Programming and Scripting

calculating the time difference, when the script was executed and the currenent file

Hi, I has created the shell script in HP_UX 11.23 and using the command, echo $(date +%Y%m%d%H%M%S) > $DIR/alert, placing the time of running the script into a file alert. I want to compare the time in the above file alert with the current time.If difference is more than 5 min, then print the... (7 Replies)
Discussion started by: velocitnitin
7 Replies

10. Shell Programming and Scripting

Create file in script

I am trying to create a new file(string) with todays date in a backup folder string= `date '+%d%m%y'` find * * * /home/SMB-2000/* -print |cpio -ovm > /home/bkups/$string After excecuting I get the messege # ./b2 ... (3 Replies)
Discussion started by: paparazi
3 Replies
Login or Register to Ask a Question