!quit is the recommended command to exit the Beeline shell.
Background Query in Terminal Script
Beeline can be run disconnected from a terminal for batch processing and automation scripts using commands such as nohup and disown.
Some versions of Beeline client may require a workaround to allow nohup command to correctly put the Beeline process in the background without stopping it. See HIVE-11717, HIVE-6758
The following environment variable can be updated:
export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Djline.terminal=jline.UnsupportedTerminal"
Running with nohangup (nohup) and ampersand (&) will place the process in the background and allow the terminal to disconnect while keeping the Beeline process running.
nohup beeline --silent=true --showHeader=true --outputformat=dsv -f query.hql </dev/null > /tmp/output.log 2> /tmp/error.log &
HiveServer2 has a JDBC driver. It supports both embedded and remote access to HiveServer2. Remote HiveServer2 mode is recommended for production use, as it is more secure and doesn't require direct HDFS/metastore access to be granted for users.