I have this question. (Write "your_username.sh" script to create a text file each time you log out. The file should contain all statements you execute during your session. The name of the text file should have the following naming pattern “Statements-20191104.0225.txt” (20191104 represents the date and 0225 represents the time). All files should be stored in the ~/MyStatements directory.)
I create sh script and call it inside .bash_logout. This script creates a file and tries to save all history inside it
#!/bin/bash
currentDateTime=$(date +"%Y%m%d.%k%M")
fileName="Statements-$currentDateTime"
touch ~/MyStatements/$fileName
echo $currentDateTime
echo $fileName
history -a "~/MyStatements/$fileName"
history -a newFile.text
A new file created inside "MyStatements" folder but this file doesn't contain any data